使用 conda 从 Anaconda 导入 numpy 时出错(DLL 加载失败:找不到指定的模块)

Error importing numpy from Anaconda, using conda (DLL load failed: The specified module could not be found)

当我使用 Anaconda 时,导入 numpy 会出现以下 错误

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File"C:\Users\s140041\Anaconda3\envs\testenv\lib\site-packages\numpy\__init__.py", line 142, in <module>
    from . import add_newdocs
  File"C:\Users\s140041\Anaconda3\envs\testenv\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "C:\Users\s140041\Anaconda3\envs\testenv\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
    from .type_check import *
  File"C:\Users\s140041\Anaconda3\envs\testenv\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File"C:\Users\s140041\Anaconda3\envs\testenv\lib\site-packages\numpy\core\__init__.py", line 26, in <module>
    raise ImportError(msg)

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.

我已经做了很多故障排除工作:

只有当我使用 conda 卸载并使用 pip 重新安装时一切正常... 我在这里做错了什么,或者 conda 在这个 Anaconda 安装中损坏了吗?

我刚从普通的 python/venv/pip 切换到 Anaconda/conda/environments,但我必须说这并不是真正的热烈欢迎...尽管我听说 conda 打包系统比 pip/venv.

更新: 我在 github 上提交了错误报告,可以在此处找到。 https://github.com/conda/conda/issues/7833

在 GitHub:

上的错误报告中可以找到关于问题的非常清楚的讨论

https://github.com/conda/conda/issues/7833

总而言之,不支持在未激活的环境中使用 PyCharm。因此,要么使用 anaconda 提示符,激活您的环境并从那里启动 PyCharm,要么重新安装 anaconda/mini-conda 并选中 "add-to-path" 选项