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)
编辑:完全错误
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/numpy/core/__init__.py", line 16, in
from . import multiarray
ImportError: cannot import name 'multiarray' from 'numpy.core' (/usr/lib/python3/dist-packages/numpy/core/__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python3/dist-packages/numpy/__init__.py", line 142, in
from . import add_newdocs
File "/usr/lib/python3/dist-packages/numpy/add_newdocs.py", line 13, in
from numpy.lib import add_newdoc
File "/usr/lib/python3/dist-packages/numpy/lib/__init__.py", line 8, in
from .type_check import *
File "/usr/lib/python3/dist-packages/numpy/lib/type_check.py", line 11, in
import numpy.core.numeric as _nx
File "/usr/lib/python3/dist-packages/numpy/core/__init__.py", line 26, in
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: 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?
EDIT 2: Contents of /usr/lib/python3/dist-packages/numpy/core
total 3672
-rw-r--r-- 1 root root 29215 Sep 29 2017 arrayprint.py
-rw-r--r-- 1 root root 413 Sep 17 2017 cversions.py
-rw-r--r-- 1 root root 67393 Sep 17 2017 defchararray.py
-rw-r--r-- 1 root root 6208 Dec 5 2017 _dummy.cpython-36m-x86_64-linux-gnu.so
-rw-r--r-- 1 root root 35533 Sep 29 2017 einsumfunc.py
-rw-r--r-- 1 root root 98980 Sep 29 2017 fromnumeric.py
-rw-r--r-- 1 root root 12104 Sep 29 2017 function_base.py
-rw-r--r-- 1 root root 7331 Sep 29 2017 generate_numpy_api.py
-rw-r--r-- 1 root root 18422 Sep 17 2017 getlimits.py
drwxr-xr-x 3 root root 4096 Mar 24 13:20 include
-rw-r--r-- 1 root root 4692 Sep 17 2017 info.py
-rw-r--r-- 1 root root 3039 Sep 29 2017 __init__.py
-rw-r--r-- 1 root root 21375 Sep 29 2017 _internal.py
drwxr-xr-x 3 root root 4096 Mar 24 13:20 lib
-rw-r--r-- 1 root root 10789 Sep 17 2017 machar.py
-rw-r--r-- 1 root root 11432 Sep 17 2017 memmap.py
-rw-r--r-- 1 root root 4704 Sep 17 2017 _methods.py
-rw-r--r-- 1 root root 1582528 Dec 5 2017 multiarray.cpython-36m-x86_64-linux-gnu.so
-rw-r--r-- 1 root root 48624 Dec 5 2017 multiarray_tests.cpython-36m-x86_64-linux-gnu.so
-rw-r--r-- 1 root root 91642 Sep 29 2017 numeric.py
-rw-r--r-- 1 root root 28786 Sep 29 2017 numerictypes.py
-rw-r--r-- 1 root root 10384 Dec 5 2017 operand_flag_tests.cpython-36m-x86_64-linux-gnu.so
drwxr-xr-x 2 root root 4096 Mar 24 13:20 __pycache__
-rw-r--r-- 1 root root 29418 Sep 29 2017 records.py
-rw-r--r-- 1 root root 15345 Dec 5 2017 setup_common.py
-rw-r--r-- 1 root root 40704 Sep 29 2017 setup.py
-rw-r--r-- 1 root root 19081 Sep 29 2017 shape_base.py
-rw-r--r-- 1 root root 10408 Dec 5 2017 struct_ufunc_test.cpython-36m-x86_64-linux-gnu.so
-rw-r--r-- 1 root root 44312 Dec 5 2017 test_rational.cpython-36m-x86_64-linux-gnu.so
drwxr-xr-x 4 root root 4096 Mar 24 13:20 tests
-rw-r--r-- 1 root root 1415520 Dec 5 2017 umath.cpython-36m-x86_64-linux-gnu.so
-rw-r--r-- 1 root root 18856 Dec 5 2017 umath_tests.cpython-36m-x86_64-linux-gnu.so
Results of locate multiarray.py
/usr/lib/python2.7/dist-packages/numpy/core/tests/test_multiarray.py
/usr/lib/python2.7/dist-packages/numpy/core/tests/test_multiarray.pyc
/usr/lib/python2.7/dist-packages/numpy/matrixlib/tests/test_multiarray.py
/usr/lib/python2.7/dist-packages/numpy/matrixlib/tests/test_multiarray.pyc
/usr/lib/python3/dist-packages/numpy/core/tests/test_multiarray.py
/usr/lib/python3/dist-packages/numpy/matrixlib/tests/test_multiarray.py