У меня установлен MSYS2 на Windows 10, и в нем я установил numpy для Python3 через pacman
:
$ pacman -Ss numpy | grep installed
mingw64/mingw-w64-x86_64-python3-numpy 1.16.2-1 [installed]
Если я запускаю оболочку MINGW64 bash
, то импортирую numpy
хорошо:
user@DESKTOP-XYXYXY MINGW64 /c/temp
$ python3 -c 'import numpy'
user@DESKTOP-XYXYXY MINGW64 /c/temp
$
Но, когда я делаю то же самое из оболочки MSYS2 bash
, сначала я должен явно добавить «site-packages» в PYTHONPATH
, чтобы найти numpy
Python - и даже тогда что-то идет не так:
user@DESKTOP-XYXYXY MSYS /c/temp
$ python3 -c 'import numpy'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'
user@DESKTOP-XYXYXY MSYS /c/temp
$ PYTHONPATH='/mingw64/lib/python3.7/site-packages' python -c 'import numpy'
Traceback (most recent call last):
File "/mingw64/lib/python3.7/site-packages/numpy/core/__init__.py", line 40, in <module>
from . import multiarray
File "/mingw64/lib/python3.7/site-packages/numpy/core/multiarray.py", line 12, in <module>
from . import overrides
File "/mingw64/lib/python3.7/site-packages/numpy/core/overrides.py", line 6, in <module>
from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/mingw64/lib/python3.7/site-packages/numpy/__init__.py", line 142, in <module>
from . import core
File "/mingw64/lib/python3.7/site-packages/numpy/core/__init__.py", line 71, in <module>
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/python.exe),
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: No module named 'numpy.core._multiarray_umath'
Оказывается, это _multiarray_umath
- это dll:
$ find / -name '*multiarray_umath*'
/mingw64/lib/python3.7/site-packages/numpy/core/_multiarray_umath-cpython-37m.dll
... поэтому я подумал, может быть, мне следуеттакже «взломать» $ PATH, но без игры в кости:
user@DESKTOP-XYXYXY MSYS /c/temp
$ PATH="$PATH:/mingw64/lib/python3.7/site-packages" PYTHONPATH='/mingw64/lib/python3.7/site-packages' python -c 'import numpy'
Traceback (most recent call last):
File "/mingw64/lib/python3.7/site-packages/numpy/core/__init__.py", line 40, in <module>
from . import multiarray
File "/mingw64/lib/python3.7/site-packages/numpy/core/multiarray.py", line 12, in <module>
from . import overrides
File "/mingw64/lib/python3.7/site-packages/numpy/core/overrides.py", line 6, in <module>
from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/mingw64/lib/python3.7/site-packages/numpy/__init__.py", line 142, in <module>
from . import core
File "/mingw64/lib/python3.7/site-packages/numpy/core/__init__.py", line 71, in <module>
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/python.exe),
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: No module named 'numpy.core._multiarray_umath'
Возможно ли каким-то образом выполнить настройку через переменные окружения, чтобы я мог использовать numpy
в Python3, также в MSYS2 bash
оболочка?