Python sndfile library not found on newly installed Mac

2.6k Views Asked by At

(my first post here) I have a problem with the librosa python library, which produces the following error.

OSError: sndfile library not found.

I installed the librosa library and the SoundFile library with pip install and with conda install -c conda-forge librosa. I also installed the libsndfile library with homebrew in an external git folder but I'm not sure if that's even the problem and if it is, where to put the git repository, in which I installed the library.

Apparently, the python environment tries to retrieve the library files from /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/_soundfile_data/libsndfile.dylib but they are actually located at opt/homebrew/lib/libsndfile.dylib.

I tried doing this:

  • export CPATH=/opt/homebrew/include

  • export LIBRARY_PATH=/opt/homebrew/lib

but it didn't work and I really don't know what else to do..

Maybe there's just some library I haven't installed or haven't installed in the right directory?

Screenshot of PyCharm console output after running a program that uses librosa

I am working on a brand new MacBook Pro M1 Max with

  • MacOS Monterey
  • Python 3.9
  • librosa 0.9.1
  • SoundFile 0.10.3
  • Newest PyCharm community edition

Thanks in advance!!

1

There are 1 best solutions below

0
On

For a sound project on python using M1 cpu (arch arm64), I have encountered the same issue.

  • conda install -c conda-forge libsndfile

working on python 3.10
might need conda activate, check brew install miniconda
miniconda is similar to pyenv/pipenv in short