解决numpy:DLLloadfailedwhileimporting_multiarra。。。
numpy:DLL load failed while importing _multiarray_umath: 不到指定的模
块。
1 问题描述
使⽤conda install numpy 装包。安装过程中⼀切正常,但是最后使⽤的时候却不⽌⼀次的报错:
先说⼀下我的环境:windows系统下使⽤ numpy1.20 + conda管理包环境 + python版本1.19
>>> import numpy
D:\python\envs\raft\lib\site-packages\numpy\__init__.py:138: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already bee from . import _distributor_init
Traceback (most recent call last):
File "D:\python\envs\raft\lib\site-packages\numpy\core\__init__.py", line 22, in <module>
from . import multiarray
File "D:\python\envs\raft\lib\site-packages\numpy\core\multiarray.py", line 12, in <module>
from . import overrides
File "D:\python\envs\raft\lib\site-packages\numpy\core\overrides.py", line 7, in <module>
_multiarray_umath import (
ImportError: DLL load failed while importing _multiarray_umath: 不到指定的模块。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\python\envs\raft\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import core
File "D:\python\envs\raft\lib\site-packages\numpy\core\__init__.py", line 48, in <module>
raise ImportError(msg)
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:
/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.8 from "D:\python\envs\"
* The NumPy version is: "1.19.2"
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: 不到指定的模块。
这真的是⼀个困扰了我很久的问题。⽹上查了很多办法,⽆⾮都是重新安装或者换个版本之类治标不治本的⽅法。当我正在使⽤某⼀个特定版本的conda 环境,我不愿意随意的
更改numpy的版本(有很多包依赖于底层的numpy版本,且这个问题我在其它的python和numpy版本中也遇到了,显然不是换个版本就可以解决的)。同时重装也是个没什么⽤
的⽅法。我重装了⼀边conda,问题还是依旧。所以把我的⽅法贴在下⾯:
2 解决
这个问题应该是⼀个导⼊包模块时候路径的问题。读者应该把“D:\anaconda3\envs\xxxx\Library\bin”添加到环境变量中。(这⾥情况可能因⼈⽽异,需要把xxxx改成⾃⼰的conda
环境。但是核⼼就是把对应环境下的Library\bin添加到环境变量中。)
当然还是建议读者先试⼀下conda uninstall / pip uninstall numpy 因为也有可能是重复安装了numpy包导致的,或者在版本不是很敏感的情况下没准更新⼀次就解决了问题。
(顺便⼀提:尽量不要混⽤pip和conda)
3关于dll
dll(全称dynamic link libraries,动态链接库)⽂件,是windows下⼀个⽤于连接函数功能供其它应⽤程序调⽤与引⼊的⽂件。由于是windows 早期架构的⼀部分,dll⽂件已经
numpy教程pdf电子书成为了很多代码构建的重要部分。有兴趣的同学可以去了解⼀下dll hell,这⾥就不展开啦
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论