1

I have a problem with librosa installation on raspberry pi. I followed the instructions from the comment @Austin from: Unable to pip install librosa in raspberry pi 3 model b+ (Raspbian stretch)

I installed llvmlite == 0.37.0, numba == 0.54.1, and numpy == 1.20.3 with LLVM11 (python 3.9.2) It seems to have installed well, I can import numba without errors, but when I try to import librosa I get an error:

RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe
Traceback (most recent call last):
  File "/home/pi/Desktop/test.py", line 1, in <module>
    import librosa
  File "/home/pi/.local/lib/python3.9/site-packages/librosa/__init__.py", line 12, in <module>
    from . import core
  File "/home/pi/.local/lib/python3.9/site-packages/librosa/core/__init__.py", line 109, in <module>
    from .time_frequency import *  # pylint: disable=wildcard-import
  File "/home/pi/.local/lib/python3.9/site-packages/librosa/core/time_frequency.py", line 10, in <module>
    from ..util.exceptions import ParameterError
  File "/home/pi/.local/lib/python3.9/site-packages/librosa/util/__init__.py", line 67, in <module>
    from .utils import *  # pylint: disable=wildcard-import
  File "/home/pi/.local/lib/python3.9/site-packages/librosa/util/utils.py", line 5, in <module>
    import scipy.ndimage
  File "/home/pi/.local/lib/python3.9/site-packages/scipy/ndimage/__init__.py", line 151, in <module>
    from ._filters import *  # noqa: F401 F403
  File "/home/pi/.local/lib/python3.9/site-packages/scipy/ndimage/_filters.py", line 37, in <module>
    from . import _nd_image
ImportError: numpy.core.multiarray failed to import
 

Could someone please help?

1 Answer 1

0

Perhaps your numpy version is too new? I faced such issues when installing librosa yesterday. I had to go figure out the correct package versions to install librosa. The below worked for me.

First install numpy, numba, scipy using apt.

sudo apt install python3-numpy python3-numba python3-scipy

The required llvm devs, tools etc. and python3-llvmlite should get installed with the numba install.

Then install librosa with a requirements file and without dependencies. We don't want to upgrade dependencies because they may not work.

First make the requirement.txt file.

sudo nano requirement.txt

Paste the below content into the file.

librosa==0.9.2
audioread==3.0.0
resampy==0.2.2
scikit-learn==1.2.2
packaging==23.1
pooch==1.7.0
soundfile==0.12.1
joblib==1.2.0
decorator==4.4.2
platformdirs==3.5.1
requests==2.25.1
six==1.16.0
threadpoolctl==3.1.0
cffi==1.15.1
pycparser==2.21

The install using pip.

pip install --no-deps -r requirement.txt

Check if it has worked by opening python and importing librosa and maybe load an audio file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.