![](/img/trans.png)
[英]Cannot find a solution to [WinError 2] File not found by AudioSegment.from_mp3
[英]Error when using pydub's AudioSegment.from_mp3 method
下面的代碼是我在第一個單元格中的導入語句。 如果重要的話,我在 Jupyter Notebook 中使用 Python 3
import sys
!python -m pip install --upgrade pip
!pip install --prefix {sys.prefix} pydub
from pydub import AudioSegment
from pydub.utils import db_to_float
AudioSegment.ffmpeg = "Users\Bill\Anaconda3\pkgs\imageio-2.3.0-py36_0\Lib\site-packages\imageio\plugins\ffmeg.py" #this is the edit referred to in the comments
在下一個單元格中,這是我唯一的代碼行,因此在導入后立即調用它。
clip = AudioSegment.from_mp3("song1.mp3")
我收到以下錯誤
FileNotFoundError Traceback (most recent call last)
<ipython-input-5-4844ec04b652> in <module>()
----> 1 clip = AudioSegment.from_mp3("song1.mp3")
~\Documents\Fall 2018\Data Vis\Untitled Folder\pydub\audio_segment.py in from_mp3(cls, file, parameters)
714 @classmethod
715 def from_mp3(cls, file, parameters=None):
--> 716 return cls.from_file(file, 'mp3', parameters)
717
718 @classmethod
~\Documents\Fall 2018\Data Vis\Untitled Folder\pydub\audio_segment.py in from_file(cls, file, format, codec, parameters, **kwargs)
663 stdin_data = file.read()
664
--> 665 info = mediainfo_json(orig_file)
666 if info:
667 audio_streams = [x for x in info['streams']
~\Documents\Fall 2018\Data Vis\Untitled Folder\pydub\utils.py in mediainfo_json(filepath)
261
262 command = [prober, '-of', 'json'] + command_args
--> 263 res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
264 output, stderr = res.communicate(input=stdin_data)
265 output = output.decode("utf-8", 'ignore')
~\Anaconda3\lib\subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors)
707 c2pread, c2pwrite,
708 errread, errwrite,
--> 709 restore_signals, start_new_session)
710 except:
711 # Cleanup if the child failed starting.
~\Anaconda3\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
995 env,
996 os.fspath(cwd) if cwd is not None else None,
--> 997 startupinfo)
998 finally:
999 # Child is launched. Close the parent's copy of those pipe
FileNotFoundError: [WinError 2] The system cannot find the file specified
我進行了兩次和三次檢查,並且我輸入的文件名是正確的,名稱 (song1) 和類型 (mp3)。 提前致謝!
在這里查看更深入的解釋,但基本上你已經改變了 ffmpeg 的絕對路徑。 最簡單的方法是刪除並重新安裝它或更改 pydub 使用的路徑,正如該帖子所建議的那樣。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.