Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Numpy import error Python3 on Raspberry Pi?

When I try to import numpy in Python3 i get an error.
I installed it via pip3 and it got installed succesfully.

sudo pip3 install numpy 

Here is the error message when i try to import numpy:

Python 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import numpy Traceback (most recent call last):   File "/usr/local/lib/python3.5/dist-packages/numpy/core/__init__.py", line 16, in <module>     from . import multiarray ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory  During handling of the above exception, another exception occurred:  Traceback (most recent call last):   File "<stdin>", line 1, in <module>   File "/usr/local/lib/python3.5/dist-packages/numpy/__init__.py", line 142, in <module>     from . import add_newdocs   File "/usr/local/lib/python3.5/dist-packages/numpy/add_newdocs.py", line 13, in <module>     from numpy.lib import add_newdoc   File "/usr/local/lib/python3.5/dist-packages/numpy/lib/__init__.py", line 8, in <module>     from .type_check import *   File "/usr/local/lib/python3.5/dist-packages/numpy/lib/type_check.py", line 11, in <module>     import numpy.core.numeric as _nx   File "/usr/local/lib/python3.5/dist-packages/numpy/core/__init__.py", line 26, in <module>     raise ImportError(msg) ImportError: Importing the multiarray numpy extension module failed.  Most likely you are trying to import a failed build of numpy. If you're working with a numpy git repo, try `git clean -xdf` (removes all files not under version control).  Otherwise reinstall numpy.  Original error was: libf77blas.so.3: cannot open shared object file: No such file or directory 
like image 701
Avm-x Avatar asked Dec 14 '18 17:12

Avm-x


People also ask

Why is import NumPy not working?

Python import numpy is not working that means eithers the module is not installed or the module is corrupted. To fix the corrupted module, uninstall it first then reinstall it.


2 Answers

Moving my comment to an answer because it seemed helpful to a few users.

You are missing a core numpy dependency. Running

sudo apt-get install python-dev libatlas-base-dev 

should fix the problem.

If that doesn't work, you can try installing RPi specific versions of numpy, see comments here.

like image 186
Bill DeRose Avatar answered Sep 23 '22 14:09

Bill DeRose


I am going to add an answer as I don't have enough reputation to comment.

I had this issue on my Raspberry Pi 4.

In my case this was fixed simply by running this in the command line:

sudo apt-get install libatlas-base-dev 

I thought initially I was missing a python module dependency, but this is a unix dependency, its shouldn't affect you python virtual environment

like image 44
Luke_V Avatar answered Sep 22 '22 14:09

Luke_V