Pydub (WindowsError: [Error 2] The system can not find the file specified)

In newer versions of pydub, you can specify the absolute path to your ffmpeg executable by setting the class attribute converter, e.g.:

from pydub import AudioSegment
AudioSegment.converter = "/usr/local/bin/ffmpeg"

In older versions the class attribute used to be ffmpeg, which is deprecated now.


In jupyter notebook this error could persist since the error is with anaconda environment. You can solve this by installing ffmpeg from conda-forge

Got to anaconda prompt and type:

conda install -c conda-forge ffmpeg

Make sure that you have ffmpeg http://www.ffmpeg.org/ installed. You can get help from this official page.

Other thing that I can think of is that ffmpeg is installed and is in your path but not in the path of the process using pydub.

If this is the reason for the error, then you can set the absolute path to ffmpeg directly like shown below:

import pydub
pydub.AudioSegment.ffmpeg = "/absolute/path/to/ffmpeg"
sound = AudioSegment.from_mp3("test.mp3")

Give this a try.


The other way is put ffmpeg.exe,ffplay.exe in the current working directory