30

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
4
  • 12
    You're missing a core dependency of numpy. Does running sudo apt-get install python-dev libatlas-base-dev fix the problem? If that doesn't work, you can try installing RPi specific versions of numpy, see comments here: reddit.com/r/raspberry_pi/comments/86dwpz/… Commented Dec 14, 2018 at 17:55
  • 5
    @BillDeRose your solution needs to rank higher in google search. thanks! Commented Feb 14, 2019 at 17:44
  • DON'T USE SUDO WITH PIP! Commented May 12, 2020 at 15:46
  • 1
    @ComputerScientist It is sometimes ok to pip with sudo, if you want to install some(trusted) package globally. On Raspberry Pi space is generally limited and you won't want to waste it by creating a venv or similar. Commented May 13, 2020 at 16:08

3 Answers 3

63

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, it also fixed my problem with importing scipy error
Heads up for some (RPi 4) users - this broke stuff, setting the default python version back to 2.7.18.
3

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

Comments

0

Installing libatlas-base-dev did not work for me.

Installing numpy==1.15.1 did.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.