running librosa & numba on raspberry pi 3

夙愿已清 提交于 2019-11-28 12:50:29

As of writing, the latest Raspbian release has llvm-3.8, so per this github comment you need to install llvmlite v0.15.0 with numba v0.30.1. If you're on a different llvm then you will need to explore what versions of llvmlite and numba to use with that version of llvm. Here are the commands that got me set up to get a successful import librosa:

sudo apt install libblas-dev llvm python3-pip python3-scipy
virtualenv --system-site-packages -p python3 env
source env/bin/activate
pip install llvmlite==0.15.0
pip install numba==0.30.1
pip install librosa

Note I'm using virtualenv and dragging in scipy and numpy from the system packages, otherwise it's hard to get the fortran & c dependencies right plus those take ages to compile on a RPi. If you want to install system-wide then drop the 2nd and 3rd line and put sudo in front of the pip commands. I've also frozen my requirements in this requirements.txt file so if you download that then you can run a single command pip install -r requirements.txt

Thanks @MatthewBerryman, you got me over the hump! On the newest Raspian release (stretch) I was successful with the following after several hours of frustration of trying to get librosa installed on Raspian jessie (which my RPi3 came with). Having said this, the following procedure may also work with jessie.

First, update your system's package list and upgrade all your installed packages to their latest versions with the command:

sudo apt-get update
sudo apt-get dist-upgrade

Install Python science stack:

sudo pip3 install numpy --upgrade 
sudo apt-get install python3-pandas

(Also seems to install matplotlib, scipy)

sudo apt-get install python3-sklearn

Then, install the low-level virtual machine, LLVM (per @MatthewBerryman, I used llvm 3.8 and llvmlite 0.15.0, and not the newest combination where I couldn't find the packages.) After installing llvm-3.8, a symbolic link needs to be defined before installing llvmlite.

sudo apt-get install llvm-3.8
sudo ln -s /usr/bin/llvm-config-3.8 /usr/bin/llvm-config
sudo pip3 install llvmlite==0.15.0
sudo pip3 install numba==0.32.0

Numba is 0.32.0 because if it's the newest (0.36), it will not import because of an llvm mismatch, and if it's a lower version, the librosa install will upgrade it to the newest version.

Finally, install librosa:

sudo pip3 install librosa

However, when trying to import librosa, it still throws and error, namely

ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory

Googling this error indicated this would fix it:

sudo apt-get install libatlas-base-dev

And it did; however, I have no idea why.

To summarize, this procedure installs librosa, and there is no error when trying this:

...$ python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
...
>>>import librosa
>>>
Niyanth

sudo pip install librosa==0.4.2 worked for me. There was warning yet works fine on Raspberry pi3 (OS:raspbian-jessie)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!