Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
973 views
in Technique[技术] by (71.8m points)

python - running librosa & numba on raspberry pi 3

I am trying to run librosa on my raspberry pi 3. After hours of searching through the internet I was finally able to install it but it still throws an error when I try to import it. First, I had problems to install the dependency llvmlite. I finally installed it with the following code: conda install -c numba llvmlite. I use python 3.4 build with miniconda.

After llvmlite was installed I was able to install librosa with pip (not possible with conda)

pi@raspberrypi:~ $ pip install librosa
Collecting librosa
Using cached https://www.piwheels.hostedpi.com/simple/librosa/librosa-
0.5.1-py3-none-any.whl
Requirement already satisfied: resampy>=0.1.2 in 
./miniconda3/lib/python3.4/site-packages (from librosa)
Requirement already satisfied: scipy>=0.13.0 in 
...
Installing collected packages: librosa
Successfully installed librosa-0.5.1

Apparently librosa is installed.

pi@raspberrypi:~ $ pip list
DEPRECATION: The default format will switch to columns in the future. 
You can use --format=(legacy|columns) (or define a format=
(legacy|columns) in your pip.conf under the [list] section) to disable 
this warning.
anaconda-client (1.0.2)
audioread (2.1.5)
awscli (1.11.170)
boto3 (1.4.7)
botocore (1.7.28)
clyent (0.4.0)
colorama (0.3.7)
conda (3.16.0)
conda-env (2.4.2)
Cython (0.27.1)
decorator (4.1.2)
docutils (0.14)
jmespath (0.9.3)
joblib (0.11)
librosa (0.5.1)
llvmlite (0.7.0.dev0+21.gcda19bd.dirty)
mock (2.0.0)
numba (0.35.0)
numpy (1.13.3)
pbr (3.1.1)
Pillow (2.9.0)
pip (9.0.1)
protobuf (3.4.0)
pyasn1 (0.3.7)
PyAudio (0.2.11)
pycosat (0.6.1)
pycrypto (2.6.1)    
python-dateutil (2.6.1)
pytz (2015.4)
PyYAML (3.12)
requests (2.7.0)
resampy (0.2.0)
rsa (3.4.2)
s3transfer (0.1.11)
scikit-learn (0.18.2)
scipy (0.19.1)
setuptools (18.1)
six (1.11.0)
tensorflow (1.1.0)
Werkzeug (0.12.2)
wheel (0.30.0)

Trying to import librosa throws the following error though:

pi@raspberrypi:~ $ python
Python 3.4.3 |Continuum Analytics, Inc.| (default, Aug 21 2015, 00:53:08) 
[GCC 4.6.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import librosa
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/miniconda3/lib/python3.4/site-packages/librosa/__init__.py", line 12, in <module>
    from . import core
  File "/home/pi/miniconda3/lib/python3.4/site-packages/librosa/core/__init__.py", line 108, in <module>
    from .time_frequency import *  # pylint: disable=wildcard-import
  File "/home/pi/miniconda3/lib/python3.4/site-packages/librosa/core/time_frequency.py", line 10, in <module>
    from ..util.exceptions import ParameterError
  File "/home/pi/miniconda3/lib/python3.4/site-packages/librosa/util/__init__.py", line 70, in <module>
    from . import decorators
  File "/home/pi/miniconda3/lib/python3.4/site-packages/librosa/util/decorators.py", line 67, in <module>
    from numba.decorators import jit as optional_jit
  File "/home/pi/miniconda3/lib/python3.4/site-packages/numba/__init__.py", line 12, in <module>
    from .special import typeof, prange
  File "/home/pi/miniconda3/lib/python3.4/site-packages/numba/special.py", line 4, in <module>
    from .parfor import prange
  File "/home/pi/miniconda3/lib/python3.4/site-packages/numba/parfor.py", line 20, in <module>
    from numba import array_analysis, postproc, typeinfer
  File "/home/pi/miniconda3/lib/python3.4/site-packages/numba/array_analysis.py", line 9, in <module>
    from numba import ir, analysis, types, config, cgutils, typing
  File "/home/pi/miniconda3/lib/python3.4/site-packages/numba/cgutils.py", line 22, in <module>
    true_bit = bool_t(1)
TypeError: 'IntType' object is not callable
>>> 

Trying to import numba throws the following error:

pi@raspberrypi:~ $ python
Python 3.4.3 |Continuum Analytics, Inc.| (default, Aug 21 2015, 00:53:08) 
[GCC 4.6.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numba
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/miniconda3/lib/python3.4/site-packages/numba/__init__.py", line 12, in <module>
    from .special import typeof, prange
  File "/home/pi/miniconda3/lib/python3.4/site-packages/numba/special.py", line 4, in <module>
    from .parfor import prange
  File "/home/pi/miniconda3/lib/python3.4/site-packages/numba/parfor.py", line 20, in <module>
    from numba import array_analysis, postproc, typeinfer
  File "/home/pi/miniconda3/lib/python3.4/site-packages/numba/array_analysis.py", line 9, in <module>
    from numba import ir, analysis, types, config, cgutils, typing
  File "/home/pi/miniconda3/lib/python3.4/site-packages/numba/cgutils.py", line 22, in <module>
    true_bit = bool_t(1)
TypeError: 'IntType' object is not callable
>>> 

Has anyone a clue what the problem could be? I am grateful for any hints or tips. Thank you!!!!!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...