Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble with importing numpy with a Pi running Python 3.5.3 #12803

Closed
raspi88 opened this issue Jan 19, 2019 · 5 comments
Closed

Trouble with importing numpy with a Pi running Python 3.5.3 #12803

raspi88 opened this issue Jan 19, 2019 · 5 comments

Comments

@raspi88
Copy link

raspi88 commented Jan 19, 2019

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

@mattip
Copy link
Member

mattip commented Jan 20, 2019

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.

@raspi88
Copy link
Author

raspi88 commented Jan 20, 2019

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!

@charris
Copy link
Member

charris commented Jan 20, 2019

Is libf77blas installed?

@mattip
Copy link
Member

mattip commented Jan 20, 2019

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.

@raspi88
Copy link
Author

raspi88 commented Jan 21, 2019

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.

@raspi88 raspi88 closed this as completed Jan 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants