question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

error when using pydub in virtualenv

See original GitHub issue

Note 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:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
rayrrrcommented, Jul 22, 2018

@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?

0reactions
jiaarocommented, Jun 1, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when using pydub's AudioSegment.from_mp3 method
I have double and triple checked and the file name I typed is correct, both the name (song1) and the type (mp3). Thanks...
Read more >
Working with wav files in Python using Pydub - GeeksforGeeks
pydub is a Python library to work with only .wav files. By using this library we can play, split, merge, edit our .wav...
Read more >
NameError: name 'pydub' is not defined - Using Streamlit
I get the follwing error from my application: NameError: name 'pydub' is not defined. I checked my local system for installed packages ...
Read more >
Play sound in Python
This doesn't have any dependencies, simply install with pip in your virtualenv and run! ... You can play sound files with the pydub...
Read more >
2021 How to Fix "No Module Named..." Error in Python
2021 How to Fix ImportError "No Module Named pkg_name" in Python! First, download the package using a terminal outside of python.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found