[英]“OSError: [Errno 2] No such file or directory” converting mp3
I'm trying to use Pydub , and I want to convert a mp3
file to wav
, as is already told here . 我正在尝试使用Pydub ,并且我想将
mp3
文件转换为wav
,正如这里已经讲到的 。
Even though the file is present I'm getting a error of No such file or directory
. 即使文件存在,我也会收到“
No such file or directory
的错误消息。
This is my code: 这是我的代码:
import os.path
print "File Present:", os.path.isfile('/home/nikhil/Documents/Python/IPython Notebooks/test.mp3')
from pydub import AudioSegment
sound = AudioSegment.from_mp3('/home/nikhil/Documents/Python/IPython Notebooks/test.mp3')
sound.export("file.wav", format="wav")
And this is the complete log cat: 这是完整的日志猫:
File Present: True
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-29-d23db5440f1d> in <module>()
9
10 from pydub import AudioSegment
---> 11 sound = AudioSegment.from_mp3('/home/nikhil/Documents/Python/IPython Notebooks/test.mp3')
12 sound.export("file.wav", format="wav")
13
/usr/local/lib/python2.7/dist-packages/pydub/audio_segment.pyc in from_mp3(cls, file, parameters)
700 @classmethod
701 def from_mp3(cls, file, parameters=None):
--> 702 return cls.from_file(file, 'mp3', parameters)
703
704 @classmethod
/usr/local/lib/python2.7/dist-packages/pydub/audio_segment.pyc in from_file(cls, file, format, codec, parameters, **kwargs)
656 stdin_data = file.read()
657
--> 658 info = mediainfo_json(orig_file)
659 if info:
660 audio_streams = [x for x in info['streams']
/usr/local/lib/python2.7/dist-packages/pydub/utils.pyc in mediainfo_json(filepath)
242
243 command = [prober, '-of', 'json'] + command_args
--> 244 res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
245 output, stderr = res.communicate(input=stdin_data)
246 output = output.decode("utf-8", 'ignore')
/usr/lib/python2.7/subprocess.pyc in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags)
709 p2cread, p2cwrite,
710 c2pread, c2pwrite,
--> 711 errread, errwrite)
712 except Exception:
713 # Preserve original exception in case os.close raises.
/usr/lib/python2.7/subprocess.pyc in _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, to_close, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite)
1341 raise
1342 child_exception = pickle.loads(data)
-> 1343 raise child_exception
1344
1345
OSError: [Errno 2] No such file or directory
( Please ignore the format of error. I prefer it this way(indented) ) ( 请忽略错误的格式。我更喜欢这样(缩进) )
What is going wrong here? 这是怎么了?
EDIT 编辑
I just saw people with the same problem, and it was because they didn't had installed the ffmpeg library. 我只是看到有人遇到同样的问题,这是因为他们没有安装ffmpeg库。 Try:
尝试:
sudo apt-get install ffmpeg
or 要么
sudo apt-get install libav-tools
Your path is used as argument in Popen function as your traceback shows. 如回溯所示,您的路径在Popen函数中用作参数。
Try adding additional quotes: 尝试添加其他引号:
sound = AudioSegment.from_mp3('"/home/nikhil/Documents/Python/IPython Notebooks/test.mp3"')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.