我已经在conda中创建了一个虚拟环境。然后,我在anaconda提示符(conda activate
)上打开了环境。然后,我安装了要在该环境中使用的任何包(例如numpy )。
当我打开jupyter notebook并运行import numpy
时,会显示以下错误
ImportError Traceback (most recent call last)
~\anaconda3\envs\new1\lib\site-packages\numpy\core\__init__.py in <module>
21 try:
---> 22 from . import multiarray
23 except ImportError as exc:
~\anaconda3\envs\new1\lib\site-packages\numpy\core\multiarray.py in <module>
11
---> 12 from . import overrides
13 from . import _multiarray_umath
~\anaconda3\envs\new1\lib\site-packages\numpy\core\overrides.py in <module>
6
----> 7 from numpy.core._multiarray_umath import (
8 add_docstring, implement_array_function, _get_implementing_args)
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-5-d4cdadb62aa7> in <module>
----> 1 import numpy
~\anaconda3\envs\new1\lib\site-packages\numpy\__init__.py in <module>
143 from . import _distributor_init
144
--> 145 from . import core
146 from .core import *
147 from . import compat
~\anaconda3\envs\new1\lib\site-packages\numpy\core\__init__.py in <module>
46 """ % (sys.version_info[0], sys.version_info[1], sys.executable,
47 __version__, exc)
---> 48 raise ImportError(msg)
49 finally:
50 for envkey in env_added:
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:\Users\<my user>\anaconda3\envs\new1\python.exe"
* The NumPy version is: "1.20.1"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed: The specified module could not be found.
我试过跑步
python
>>>import numpy
在anaconda提示中,它确实成功地导入了它。即使在jupyter笔记本中,当我运行help("modules")
时,numpy也会显示为列出的模块之一。
预期的行为是应该导入已安装的模块。
另外,如果我遗漏了什么,请告诉我,这是我在stackoverflow上的第一篇帖子。
发布于 2021-05-04 15:01:06
通常你会打开anaconda导航器,然后转到左侧的Enviroments,然后在底部点击" add“来添加一个新的环境。之后,您可以单击新创建的环境并“打开终端”。在终端中使用:conda install -c anaconda numpy
。现在,您应该能够直接从anaconda导航器打开jupyter笔记本,也可以通过终端启动它,一切都应该正常工作。
如果它仍然不工作,尝试重新启动anaconda,它不应该被要求,但有时它对我来说是有效的。
https://stackoverflow.com/questions/67384188
复制