error when using pydub in virtualenv
See original GitHub issueNote from maintainers
The most common reason for OSError: [Errno 2] No such file or directory is that your converter (ffmpeg or avconv) was not found. In that case, the missing file referred to by “No such file” is the ffmpeg executable file (or avconv, as the case may be)
original issue continues below…
Steps to reproduce
Create a virtualenv.
virtualenv aud
Install pydub using pip after activating virtualenv.
pip install pydub
Set up all the ffmpeg requirements.
sound = AudioSegment.from_mp3(audio_file)
Expected behavior
I should not get the error that I mentioned below
Actual behavior
Error:
File "/Users/bear/Sites/venv/aud/lib/python2.7/site-packages/pydub/audio_segment.py", line 522, in from_mp3
return cls.from_file(file, 'mp3', parameters)
File "/Users/bear/Sites/venv/aud/lib/python2.7/site-packages/pydub/audio_segment.py", line 505, in from_file
p = subprocess.Popen(conversion_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Your System configuration
- Python version: 2.7
- Pydub version: 0.20.0
- ffmpeg or avlib?: ffmpeg
- ffmpeg/avlib version: 3.4
- OS: macOs High Sierra
Is there an audio file you can include to help us reproduce?
You can include the audio file in this issue - just put it in a zip file and drag/drop the zip file into the github issue.
You can import any audio file that you have.
Also, when I do all of it without creating a virtual env and using the native macOs python, everything works. So, I am guessing there’s an issue with loading ffmpeg?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)

Top Related StackOverflow Question
@nikhileshva it looks like this could just be an issue with file I/O. Have you double-checked that you’re running your script from the directory containing the audio file, or alternately, using an absolute path to the audio file?
usually this error is because pydub (python, really) can’t find ffmpeg or avconv. The missing file is ffmpeg, not the audio file.
Also, closing due to age.