Cannot import numpy in Python 3.7 or Python 3.8 - Ubuntu 18.04
See original GitHub issueHello! Hope all the devs are staying safe during corona time and thanks for making such a great package.
I manage a group of users so I’m trying to figure out how I can install numpy
for all of them to use without having everyone install the package themselves.
I have Python 2.7.17 and Python 3.6.9 (installed by default through Ubuntu 18.04). Additionally, I have installed Python 3.7.5, Python 3.8.0, and numpy
using the following.
sudo apt install python3.7
sudo apt install python3.8
sudo apt install python3-numpy
If I run python
or python3
or python3.6
which (invokes python 2.7.17 or python 3.6.9), I can run the following command just fine.
import numpy
However, if I try to run the above after running python3.7
or python3.8
I get the following error message:
ImportError: cannot import name 'multiarray' from 'numpy.core' (/usr/lib/python3/dist-packages/numpy/core/__init__.py)
When I install numpy
it gets installed to /usr/lib/python3/dist-packages which should be fine since it’s on the sys.path()
for all versions of Python.
Could it not be working because the version of numpy
being pulled using apt is only for Python 3.6.9? If that’s the case, how should I install numpy
for all users for ALL versions of Python?
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (9 by maintainers)
That’s definitely not fine, NumPy contains C code and compiled Python extensions are specific to a minor Python version - you cannot mix 3.6 / 3.7 / 3.8
Correct
You need to install a Python version per Python version. Probably as simple as:
and actually probably better to get rid of your apt-installed
python3-numpy
and dosudo python3.6 -m pip install numpy
for symmetryFor
venv
vsvirtualenv
- since a recent comprehensive refactor,virtualenv
can now usevenv
under the. hood - see : https://virtualenv.pypa.io/en/stable/user_guide.html#creators