【发布时间】:2021-07-25 05:00:18
【问题描述】:
我使用 anacondaprompt 创建了一个 conda 环境 dmtenv 并在激活的 testenv 中执行了以下命令,以便能够将我的 conda 环境设置为 jupyter 内核(如this post):
conda install -c conda-forge ipykernel
python -m ipykernel install --user --name dmtenv
在此之后,可以选择内核和runs,但是当我尝试导入numpy或pandas等包时,它给出了这个错误:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
~\anaconda3\envs\dmtenv\lib\site-packages\numpy\core\__init__.py in <module>
21 try:
---> 22 from . import multiarray
23 except ImportError as exc:
~\anaconda3\envs\dmtenv\lib\site-packages\numpy\core\multiarray.py in <module>
11
---> 12 from . import overrides
13 from . import _multiarray_umath
~\anaconda3\envs\dmtenv\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 while importing _multiarray_umath: Kan opgegeven module niet vinden.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-7-0aa0b027fcb6> in <module>
----> 1 import numpy as np
~\anaconda3\envs\dmtenv\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\dmtenv\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.9 from "C:\Users\maxzw\anaconda3\envs\dmtenv\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 while importing _multiarray_umath: Cannot find module.
我运行 python 3.9.5 和 numpy 1.20.1。在基本 conda 环境中导入包确实有效!
我真的不知道该怎么办。非常感谢任何帮助!
编辑:
我也试过nb_conda,这给了我同样的问题。
【问题讨论】:
-
你试过在环境中安装包吗?
-
在激活环境的情况下为每个包进行 conda 安装
-
还要检查您的 PATH 环境变量在 Windows 上是否正确
-
是的,我已经在环境上安装了包,并且在jupyter运行期间激活了环境。该代码在具有常规 .py 文件的 pycharm 上正常工作,但我也需要它在 jupyter notebook 上工作。如何检查我的 PATH 变量是否正确?我应该在哪里看,它应该是什么样子?
标签: python jupyter-notebook anaconda jupyter conda