1

(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!!

jonasblome
  • 21
  • 4
  • Does this answer your question? [MacOS brew install libsndfile but still not found](https://stackoverflow.com/questions/70737503/macos-brew-install-libsndfile-but-still-not-found) – esqew Jun 07 '22 at 01:49
  • 1
    @esqew kind of, but not fully, so I found that there are sndfile.h files in opt/homebrew/Cellar/libsndfile/1.1.0/include and opt/anaconda/include. I executed the export terminal lines from your linked thread but nothing changed and the program still has the same error. There are also the by PyCharm required library files (libvorbis....dylib and libsndfile.dylib) under opt/homebrew/lib. But these apparently cannot be found by my global or conda python environment – jonasblome Jun 07 '22 at 02:56
  • Same issue here - have also tried that post but to no avail – Kalvin Chang Jun 28 '22 at 01:47
  • workaround https://github.com/bastibe/python-soundfile/issues/310#issuecomment-1032744314 – Kalvin Chang Jun 28 '22 at 06:52

1 Answers1

4

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

Alsushi
  • 373
  • 3
  • 14