【问题标题】:Why can I not import numpy in terminal while being able to import it in Jupyter notebook?为什么我不能在终端中导入 numpy 而能够在 Jupyter 笔记本中导入它?
【发布时间】:2019-03-05 19:51:03
【问题描述】:

今天我决定更新我的 Anaconda 发行版。但更新后,当我尝试在终端或 VScode 中导入 numpy 时,我收到以下错误消息(我只是引用了最后几行)

import numpy


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: DLL load failed: The specified module could not be found.

但是,在 Jupyter notebook 中导入 numpy 是完全可以的。我想知道我的问题的根源是什么以及如何解决这个问题。提前致谢!

【问题讨论】:

  • “我决定更新我的 Anaconda 发行版”到底是什么意思?
  • 你是否安装了多个python?
  • 听起来您要么像@busybear 所说的那样使用不同的python 安装,要么使用具有不同版本numpy 的虚拟环境
  • 奇怪的是我实际上只有一个版本的python,并且我确保将其余所有版本都删除。我认为证明它的方法是在终端中输入“where python”并在笔记本中运行 sys.executable,它们指向同一个 python.exe 文件。
  • 终端和笔记本中的sys.path 是什么?他们可能正在寻找不同版本的 numpy。

标签: python numpy anaconda jupyter-notebook


【解决方案1】:

Anaconda 带有自己的 Numpy,这就是为什么您可以在 Jupyter 中访问它。您必须为您的 Python 版本找到正确的安装文件。当您打开终端时,您应该能够看到这一点。

【讨论】:

  • 感谢您的评论,但奇怪的是我实际上只有一个版本的python,并且我确保将其余所有版本都删除。我认为证明它的方法是在终端中输入“where python”并在笔记本中运行 sys.executable,它们指向同一个 python.exe 文件。
  • 在你的 shell 中寻找类似的东西并在搜索正确的 Wheel EX([MSC v.1915 32 bit (Intel)] on win32)时使用它
猜你喜欢
  • 2018-09-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-11
  • 2023-03-07
  • 2020-11-30
  • 1970-01-01
  • 1970-01-01
  • 2016-11-18
相关资源
最近更新 更多