【发布时间】:2021-04-20 18:08:15
【问题描述】:
背景
就在两天前,我能够运行任何具有 numpy 依赖项的程序。现在,当我尝试使用 pandas、matplotlib 或任何依赖于 numpy 的模块运行我的代码时,我收到以下错误:
Traceback (most recent call last):
File "<ipython-input-8-8fcf286af663>", line 7, in <module>
import numpy
File "path\to\Python\Python38\site-packages\numpy\__init__.py", line 140, in <module>
from . import core
File "path\to\Python\Python38\site-packages\numpy\core\__init__.py", line 48, 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.7 from "C:\ProgramData\Anaconda3\pythonw.exe"
* The NumPy version is: "1.19.5"
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'
设置检查
返回消息引用了此站点:https://numpy.org/devdocs/user/troubleshooting-importerror.html,但没有任何帮助。
我检查了我的 Path 变量以确保所有必需的目录位置都在那里并且没有问题。
当我使用python -c "import numpy; print('done')"从cmd编译代码时成功导入numpy
我正在使用 anaconda 环境,即 Spyder IDE,而且两天前还好。
我从pythonw.exe检查了python版本,看起来也不错
我的环境可能有什么问题?
这里尝试的解决方案
另外,我检查了以下链接,但没有成功:
Importing the numpy c-extensions failed
importing numpy package in Spyder, Python
python Spyder not importing numpy
https://github.com/numpy/numpy/issues/15090
Import error: Anaconda numpy (numpy and Anaconda already installed, virtualenv)
【问题讨论】:
标签: python python-3.x numpy anaconda spyder