No module named soundfile
Solution 1
Check if it is installed in a test environment
Example Ways
$ pip install virtualenv
$ python -m virtualenv venv
$ source venv/bin/activate
$ pip install pysoundfile
$ python
>>> import soundfile
Solution 2
I had the same problem, I guess the problem is with python versions. When I tried with Python 3.5.2
python3 file_name.py
ImportError: No module named 'soundfile'
Instead, I tried the same with Python 2.7.12
python file_name.py
It successfully imported it!
Solution 3
PySoundFile depends on the Python packages CFFI and NumPy, and the system library libsndfile.
To install the Python dependencies, I recommend using the Anaconda distribution of Python 3.
This will come with all dependencies pre-installed. To install the dependencies manually, you can use the conda package manager, which will install all dependencies using conda install cffi numpy
(conda is also available independently of Anaconda with pip install conda
).
With CFFI and NumPy installed, you can use pip install pysoundfile
to download and install the latest release of PySoundFile. On Windows and OS X, this will also install the library libsndfile. On Linux, you need to install libsndfile using your distribution's package manager, for example sudo apt-get install libsndfile1
.
theonlygusti
Updated on June 27, 2022Comments
-
theonlygusti almost 2 years
Whenever I try to import
soundfile
I get the errorImportError: No module named soundfile
I installed pysoundfile seemingly without trouble:
$ sudo pip install pysoundfile The directory '/Users/theonlygusti/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/Users/theonlygusti/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Collecting pysoundfile Downloading PySoundFile-0.9.0.post1-py2.py3.cp26.cp27.cp32.cp33.cp34.cp35.cp36.pp27.pp32.pp33-none-macosx_10_5_x86_64.macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.whl (573kB) 100% |████████████████████████████████| 573kB 430kB/s Requirement already satisfied: cffi>=0.6 in /Library/Python/2.7/site-packages (from pysoundfile) Requirement already satisfied: pycparser in /Library/Python/2.7/site-packages (from cffi>=0.6->pysoundfile) Installing collected packages: pysoundfile Successfully installed pysoundfile-0.9.0.post1
so what's causing this problem?
-
Admin over 6 yearsDoes the
python
executable you're using match thepip
executabel you're using? -
Honza Sedloň over 6 yearsPip install by default install package for python 2.7. Are you usinh Python 2.7?
-
theonlygusti over 6 years@Evert I ran
which
on both, got/usr/local/bin/python
and/usr/local/bin/pip
. Not sure how to check if it's the same forsudo
, but runningsudo which
returned the same. That might not be the correct way to diagnose though. -
theonlygusti over 6 years@HonzaSedloň Python 2.7.13, pip 9.0.1
-
Mayra Delgado over 6 yearsSearch the module file (use
find
). Then see if the ancestor-library-path is included insys.path
-
theonlygusti over 6 years@MayraDelgado where's the module file?
-
Admin over 6 yearsIt's weird that something in
/usr/local
wants to install things in/Library/Python
. Who has permissions to/usr/local/
? Root, admin or your normal user account? Also, how did you install that Python version in the first place? The path suggests Homebrew, and Homebrewn Python/pip would never install anything in/Library/Python
. -
theonlygusti over 6 years@Evert I don't know
-
Admin over 6 yearsWell, you should be able to find out the permissions easily:
ls -la /usr/local
should already tell you. And if there's a/usr/local/Homebrew/
directory, it's likely all installed by Homebrew.
-