26

while using import soundfile on wither python3 or python I am getting:

Traceback (most recent call last): File "", line 1, in File "/home/erezsh/.local/lib/python3.6/site-packages/soundfile.py", line 142, in raise OSError('sndfile library not found') OSError: sndfile library not found

I found this post which did not help because I am using soundfile and not pysoundfile and the link it offers is broken.

Also, here I could not find a solution since I have installed using pip install SoundFile.

I am using Ubuntu shell on windows. Is this of any importance?

How do I solve this?

havakok
  • 1,185
  • 2
  • 13
  • 45

5 Answers5

53

You need to install the needed library:

On Linux, you need to install libsndfile using your distribution’s package manager, for example sudo apt-get install libsndfile1.

From PyPI

handras
  • 1,548
  • 14
  • 28
17

handras answer (from 2019) is not working now (in 2020) so install libsndfile1 via ( as A.B.)

sudo apt-get install libsndfile1-dev
Adam
  • 1,254
  • 12
  • 25
8

Try using the conda installation is you do not have sudo priviliges.

It worked for me, while I continued to face issues via the pip installation.

conda install -c conda-forge librosa

The above command installs librosa. You might be able to find a specific one for only soundfile too.

3

UPDATE: Needed to run apt update first, and it worked.

The accepted answer at first did not work for me.

I'm inside a docker image:

apt-get install libsndfile1
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libsndfile1
Ryan
  • 31
  • 1
2

in case of yum package manager users first install the dependency

 sudo yum -y install libsndfile

afterwards run the pip installs

pip install SoundFile
pip install librosa
Joe Web
  • 558
  • 5
  • 11