【发布时间】:2020-02-08 20:23:45
【问题描述】:
当尝试在 spyder 中导入 numpy 时,我收到以下错误消息:
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
1. Check that you expected to use Python3.7 from "/home/sltzgs/anaconda3/bin/python",and that you have no directories in your PATH or PYTHONPATH that can interfere with the Python and numpy version "1.17.2" 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
- If you're working with a numpy git repository, trygit clean -xdf(removes all files not under version control) and rebuild numpy.
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'
但是,在 jupyter notebook 中导入可以正常工作。这怎么可能? 到目前为止,我已经卸载/安装了 numpy 几次,并确保 sys.paths 是相同的。
任何帮助表示赞赏。如果需要任何其他信息,我很乐意提供帮助。谢谢。
一些要点: 蟒蛇3.7 蜘蛛 3.3.6 numpy 1.17.2
【问题讨论】:
-
从消息中,错误来自 Python 3.6,但您使用的是 3.7,是吗?确保 Spyder 正在查看正确的 Py 安装。此外,查看您的
/.../site-packages/numpy/core并查看两种安装是否存在_multiarray_umath。这应该可以帮助您开始追踪它... -
请以文字形式报错。
-
你是单独使用spyder(然后通过pip安装)还是通过anaconda使用?
-
@Mathieu > 通过 anaconda
-
我认为您使用 pip 安装 numpy 损坏了 Anaconda 安装,因此您应该卸载它并重新安装。