2

Goal:

Install Python3.7 on the Raspberry Pi. Then install Numpy for Python3.7

Found this very useful Github Gist: https://gist.github.com/SeppPenner/6a5a30ebc8f79936fa136c524417761d

Ran the following code in the console on the Pi(took ~1hour):

sudo apt-get update -y
sudo apt-get install build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev libffi-dev -y
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar xf Python-3.7.0.tar.xz
cd Python-3.7.0
./configure
make -j 4
sudo make altinstall
cd ..
sudo rm -r Python-3.7.0
rm Python-3.7.0.tar.xz
sudo apt-get --purge remove build-essential tk-dev -y
sudo apt-get --purge remove libncurses5-dev libncursesw5-dev libreadline6-dev -y
sudo apt-get --purge remove libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev -y
sudo apt-get --purge remove libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev libffi-dev -y
sudo apt-get autoremove -y
sudo apt-get clean

I then upgraded pip:

sudo python3.7 -m pi installl --upgrade pip

and finally installed Numpy for Python3.7 using pip:

sudo python3.7 -m pip install numpy

When trying to import numpy into python3.7 I got the (first) ImportError:

>>>import numpy as np
Traceback (most recent call last):
   File "/usr/local/lib/python3.7/site-packages/numpy/core/__init__.py", line 40, in <module>
     from . import multiarray
   File "/user/local/lib/python3.7/site-packages/numpy/core/multiarray.py" line 12, in <module>
     from . import overrides
   File "/usr/local/lib/python3.7/site-packages/numpy/core/overrides.py", line 6, in <module>
     from numpy.core._multiarray_umath import (
ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory

I did install libf77blas.so.3 by typing:

sudo apt-get install libatlas-base-dev  

But upon importing numpy I got another import error, this time numpy can't find /lib/arm-linux/gnuabihf/libm.so.6: version 'GLIBC_2.27'

I was not able to find a way to install GLIBC_2.27

3

The solution was surprisingly simple:

Install an older Numpy version - I went with:

sudo python3.7 -m pip install 'numpy>1.0, <1.15' --force-reinstall

The installation took looong, but I'm now able to import numpy in python3.7

Hope this helps someone..I spent way too much time figuring this out

1

GLIBC_2.27 is not a library, it means that a symbol from libc with version 2.27 (or higher) is needed. You can try to install the glibc from the same repository where you got the libatlas-base-dev, they should have a compatible version. libm is part or glibc.

Newer versions of glibc should be upward compatible with older versions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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