question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

numpy not importing in python3.7 virtualenv

See original GitHub issue

Reproducing code example:

import numpy

Error message:

Traceback (most recent call last):
  File "/home/pi/.virtualenvs/print3.7/lib/python3.7/site-packages/numpy/core/__init__.py", line 17, in <module>
    from . import multiarray
  File "/home/pi/.virtualenvs/print3.7/lib/python3.7/site-packages/numpy/core/multiarray.py", line 14, in <module>
    from . import overrides
  File "/home/pi/.virtualenvs/print3.7/lib/python3.7/site-packages/numpy/core/overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
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 "main_commandline.py", line 7, in <module>
    import numpy as np
  File "/home/pi/.virtualenvs/print3.7/lib/python3.7/site-packages/numpy/__init__.py", line 142, in <module>
    from . import core
  File "/home/pi/.virtualenvs/print3.7/lib/python3.7/site-packages/numpy/core/__init__.py", line 47, in <module>
    raise ImportError(msg)
ImportError: 

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

Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
  1. Check that you expected to use Python3.7 from "/home/pi/.virtualenvs/print3.7/bin/python",
     and that you have no directories in your PATH or PYTHONPATH that can
     interfere with the Python and numpy version "1.17.2" 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

- If you're working with a numpy git repository, try `git clean -xdf`
  (removes all files not under version control) and rebuild numpy.

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

Numpy/Python version information:

>>> import sys, numpy; print(numpy.__version__, sys.version)
Traceback (most recent call last):
  File "/home/pi/.virtualenvs/print3.7/lib/python3.7/site-packages/numpy/core/__init__.py", line 17, in <module>
    from . import multiarray
  File "/home/pi/.virtualenvs/print3.7/lib/python3.7/site-packages/numpy/core/multiarray.py", line 14, in <module>
    from . import overrides
  File "/home/pi/.virtualenvs/print3.7/lib/python3.7/site-packages/numpy/core/overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
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 "/home/pi/.virtualenvs/print3.7/lib/python3.7/site-packages/numpy/__init__.py", line 142, in <module>
    from . import core
  File "/home/pi/.virtualenvs/print3.7/lib/python3.7/site-packages/numpy/core/__init__.py", line 47, in <module>
    raise ImportError(msg)
ImportError: 

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

Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
  1. Check that you expected to use Python3.7 from "/home/pi/.virtualenvs/print3.7/bin/python",
     and that you have no directories in your PATH or PYTHONPATH that can
     interfere with the Python and numpy version "1.17.2" 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

- If you're working with a numpy git repository, try `git clean -xdf`
  (removes all files not under version control) and rebuild numpy.

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

Info that the error message requested:

 - how you installed Python: Python3.7 comes pre-installed with Raspbian Buster. Made a virtualenv using 3.7
 - how you installed numpy: In my venv, `pip3 install numpy`
 - your operating system: Raspbian Buster, apt-get updated and upgraded.
 - whether or not you have multiple versions of Python installed: 2.7 and 3.7 by default.  Added 3.6 myself (sudo apt-get install python3.6-dev) but am not using it for this.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
EdwardChamberlaincommented, Apr 10, 2020

I also had this issue. For me running sudo apt-get install libatlas-base-dev fixed it. It seems this is an issue with piwheels.

0reactions
Danie12345commented, Dec 1, 2022

I believe it was just one of those situations where the selected environment was not being used. And running that piece of code confirms it. I’ve managed to get around it by running the file with a button, which finds the file and runs it using the selected environment for me.

Sorry for the trouble, and thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Install python-numpy in the Virtualenv environment
Python told me "No modules named numpy". Whereas, numpy could be imported in Python globally. I tried to remove and install many times...
Read more >
ModuleNotFoundError: No module named 'numpy' in Python
The Python "ModuleNotFoundError: No module named 'numpy'" occurs when we forget to install the numpy module before importing it or install it in ......
Read more >
Setting up and using your development environment - NumPy
To build the development version of NumPy and run tests, spawn interactive shells with the Python import paths properly set up etc., do...
Read more >
[Solved] No Module Named Numpy in Python
Whenever an external module (numpy) is imported in python, it checks the package in the site packages folder if it's available. If not...
Read more >
How does python find packages?
import numpy > numpy.__file__ '/usr/local/lib/python2.7/dist-packages/numpy/__init__.pyc'. However, the Python docs state that: The file attribute is not ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found