Numpy: Trouble with importing numpy with a Pi running Python 3.5.3

Created on 19 Jan 2019  ·  5Comments  ·  Source: numpy/numpy

Hello,

I'm new to Raspberry Pi, using the 3B+. Using the Thonny IDE. Trying to just import matplotlib and getting errors related to Numpy. I am running Python 3.5.3. matplotlib 3.0.2 and numpy 1.16.0. Below, as the template states, is my code (just importing matplotlib.pyplot). This is a new Pi. All I have done is had the system update upon setup, and updated both matplotlib and numpy to get them to their most recent stable version. Any help you can give me to help me solve this would be appreciated.

import matplotlib.pyplot as plt

Below is the error message I receive in the shell:
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.5/site-packages/numpy/core/__init__.py", line 16, in
from . import multiarray
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 317, in _custom_import
module = self._original_import(args, *kw)
File "/home/pi/.local/lib/python3.5/site-packages/numpy/core/multiarray.py", line 12, in
from . import overrides
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 317, in _custom_import
module = self._original_import(args, *kw)
File "/home/pi/.local/lib/python3.5/site-packages/numpy/core/overrides.py", line 9, in
from numpy.core._multiarray_umath import add_docstring, ndarray
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 317, in _custom_import
module = self._original_import(args, *kw)
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 "/home/pi/Documents/Test/Test.py", line 1, in
import matplotlib.pyplot as plt
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 317, in _custom_import
module = self._original_import(args, *kw)
File "/home/pi/.local/lib/python3.5/site-packages/matplotlib/__init__.py", line 141, in
from . import cbook, rcsetup
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 317, in _custom_import
module = self._original_import(args, *kw)
File "/home/pi/.local/lib/python3.5/site-packages/matplotlib/cbook/__init__.py", line 33, in
import numpy as np
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 317, in _custom_import
module = self._original_import(args, *kw)
File "/home/pi/.local/lib/python3.5/site-packages/numpy/__init__.py", line 142, in
from . import core
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 317, in _custom_import
module = self._original_import(args, *kw)
File "/home/pi/.local/lib/python3.5/site-packages/numpy/core/__init__.py", line 47, in
raise ImportError(msg)
ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
Here is how to proceed:

  • If you're working with a numpy git repository, try git clean -xdf
    (removes all files not under version control) and rebuild numpy.
  • If you are simply trying to use the numpy version that you have installed:
    your installation is broken - please reinstall numpy.
  • If you have already reinstalled and that did not fix the problem, then:

    1. Check that you are using the Python you expect (you're using /usr/bin/python3),

      and that you have no directories in your PATH or PYTHONPATH that can

      interfere with the Python and numpy versions you're trying to use.

    2. If (1) looks fine, you can open a new issue at

      https://github.com/numpy/numpy/issues. Please include details on:



      • how you installed Python


      • how you installed numpy


      • your operating system


      • whether or not you have multiple versions of Python installed


      • if you built from source, your compiler versions and ideally a build log



 Note: this error has many possible causes, so please don't comment on
 an existing issue about this - open a new one instead.

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

Most helpful comment

So I was able to solve the problem thanks to the help of the great community here. Using
sudo apt-get install libatlas-base-dev
fixed the issue. I guess Rasbian did not have all of the dependent libraries.

Hopefully this will be helpful to some other new users! Thanks everyone for your help.

All 5 comments

updated both matplotlib and numpy to get them to their most recent stable version

How did you do this? You apparently are missing something in your libblas3 installation or libblas3-dev installation from apt get install.

Mattip,

I used ‘sudo apt-get install matplotlib’ and ‘sudo apt-get install numpy’

Is there a better way to do this?

Thank you for your help!

Is libf77blas installed?

apt get does not use our code, rather packages produced by your OS maintainer. While it is the best method to make sure everything is properly updated to the same version, apparently something went wrong. You should carefully observe any warnings or error messages when you install, and look on your OS maintainer's issue tracker for similar problems.

So I was able to solve the problem thanks to the help of the great community here. Using
sudo apt-get install libatlas-base-dev
fixed the issue. I guess Rasbian did not have all of the dependent libraries.

Hopefully this will be helpful to some other new users! Thanks everyone for your help.

Was this page helpful?
0 / 5 - 0 ratings