[英]Exception has occurred: ImportError "No module named 'numpy.core._multiarray_umath'"
WHAT I'M DOING:我在做什么:
I'm trying to import numpy:我正在尝试导入 numpy:
import numpy
but I'm getting the following error:但我收到以下错误:
Exception has occurred: ImportError
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.9 from "C:\Users\jack_l\AppData\Local\Programs\Python\Python39\python.exe"
* The NumPy version is: "1.22.4"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'
During handling of the above exception, another exception occurred:
I've gone through the help website and I couldn't find anything that helped (I tried everything, but IDK if I tried everything correctly :/).我浏览了帮助网站,但找不到任何有帮助的东西(我尝试了所有方法,但如果我正确尝试了所有方法,IDK :/)。
WHAT I'VE DONE AND WHAT I'VE FOUND:我做了什么,我发现了什么:
py --version
in the PowerShell terminal, it says I'm on Python 3.10.4 (image 2)py --version
时,它说我在 Python 3.10.4 上(图 2)os.environ.get('PYTHONPATH')
, it gives me c:\users\jack_l\appdata\local\programs\python\python310\lib\site-packages
, which I don't think is right but I don't know how to fix it.os.environ.get('PYTHONPATH')
时,它给了我c:\users\jack_l\appdata\local\programs\python\python310\lib\site-packages
,我认为这是不对的,但我不知道如何解决。 Image 1:图 1:
Image 2:图 2:
FULL ERROR TRACEBACK:完整的错误回溯:
Traceback (most recent call last):
File "c:\users\jack_l\appdata\local\programs\python\python310\lib\site-packages\numpy\core\__init__.py", line 23, in <module>
from . import multiarray
File "c:\users\jack_l\appdata\local\programs\python\python310\lib\site-packages\numpy\core\multiarray.py", line 10, in <module>
from . import overrides
File "c:\users\jack_l\appdata\local\programs\python\python310\lib\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 "c:\Users\jack_l\Documents\CAR_MIX\mega.py", line 8, in <module>
import numpy as np
File "c:\users\jack_l\appdata\local\programs\python\python310\lib\site-packages\numpy\__init__.py", line 144, in <module>
from . import core
File "c:\users\jack_l\appdata\local\programs\python\python310\lib\site-packages\numpy\core\__init__.py", line 49, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.9 from "C:\Users\jack_l\AppData\Local\Programs\Python\Python39\python.exe"
* The NumPy version is: "1.22.4"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'
If you recive this error probably the numpy library was installed in something like this: C:\Users\Administrator\AppData\Local\Programs\Python\Python38\Lib
.I think that you have used pip install numpy
out of the virtual environment and when you have imported numpy, Python couldn't find it.To fix it try to install numpy in virtual environment and it will be stored at name_virtualenv/Lib/site-packeges
.如果您收到此错误,则 numpy 库可能安装在以下位置:
C:\Users\Administrator\AppData\Local\Programs\Python\Python38\Lib
。我认为您已经在虚拟环境中使用了pip install numpy
并且当您导入 numpy 时,Python 找不到它。要修复它,请尝试在虚拟环境中安装 numpy,它将存储在name_virtualenv/Lib/site-packeges
中。
Create virtual environment:创建虚拟环境:
python -m virtualenv name
The folders Include, Scripts and Lib will be created automatically python -m virtualenv name
将自动创建文件夹 Include、Scripts 和 Lib
Activate启用
Before activate the virtual environment go to name\Scripts cd name\Scripts
在激活虚拟环境之前转到 name\Scripts
cd name\Scripts
Then: .\activate
然后:
.\activate
Install python-package安装 python 包
Install numpy with this command: pip install numpy
.使用以下命令安装 numpy:
pip install numpy
。 Now numpy is stored at this path: Lib/site-packeges
现在 numpy 存储在这个路径:
Lib/site-packeges
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.