Install NumPy in Raspbian/Raspberry OS avoiding ImportError exceptions

If you are trying to install some scientific Python packages (like Astropy, for instance) in your Raspberry Pi, it is quite likely that you will find an error message like this while trying to use NumPy:

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

If that’s the case, what happens is that NumPy, as a pre-compiled package, it is trying to access the shared library libf77blas.so.3, which does not exist in a normal Raspberry OS installation.

In order to rectify that issue, you just need to install it by invoking the following command:

sudo apt-get install libatlas-base-dev

After that, the following commands:

pip uninstall numpy; pip install numpy

should work (the comments assume you had a non-working NumPy installation that needs to be removed; if not, you can just issue the command after the semicolon, ;).

Please remember that you should be using preferably a virtual Python environment with VirtualEnv, and then use pip for each of those environments.

But if you just want to install NumPy available for all users, you can use the following command:

pip3 uninstall numpy # remove previously installed version
apt install python3-numpy

Hope that was useful!

Via NumPy: Troubleshooting ImportError.

Descubre más desde Memoria de Acceso Aleatorio

Suscríbete ahora para seguir leyendo y obtener acceso al archivo completo.

Seguir leyendo