Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have a problem with Pydub module running in Windows and Linux. When I try open a mp3 file thus:

from pydub import AudioSegment
sound = AudioSegment.from_mp3("test.mp3")

Console show me the next message:

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

But...I have the file (test.mp3) in the same folder that the script, the name is correct.

Why I have this problem? (In Linux, have the same error)

like image 669
gasgen Avatar asked Mar 09 '14 15:03

gasgen


3 Answers

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
like image 135
Adhishwar Singh Mittal Avatar answered Nov 05 '22 17:11

Adhishwar Singh Mittal


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.

like image 16
ρss Avatar answered Nov 05 '22 18:11

ρss


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

like image 13
Chaitu Boggavarapu Avatar answered Nov 05 '22 16:11

Chaitu Boggavarapu