DLL load failed: the specified module could not be found Windows 10 shell

邮差的信 提交于 2020-02-15 18:10:46

问题


I'm trying to run a Python script from the Windows shell, but when I do

python path\to\file\script.py

I get an error "DLL load failed: The specified module could not be found" and it traces back to the line where I import numpy.

C:\Users\Admin>python path\to\file\script.py
Traceback (most recent call last):
  File "path\to\file\script.py", line 8, in <module>
    import numpy as np
  File "C:\Users\Admin\Anaconda3\lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init
  File "C:\Users\Admin\Anaconda3\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
    from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.

The weird part is that when I run it in an editor like Spyder, numpy imports just fine. Can someone help me?

Thanks


回答1:


It's fixed Anaconda path issue. Check your %PATH% if it's correctly defined.

Source: https://github.com/numpy/numpy/issues/12957




回答2:


This is a common problem when installing python packages, mainly in windows.

Numpy and other packages have bindings to C++ code that require some special dependencies.

Rather than trying to get the dependencies exactly right for compiling the package, you can use a precompiled "wheel" file from one of several sources.

I use Chris Gholke's site

download the .whl file and install using

pip install directory/path/package.whl

edit: and as a note, the python environment you access from powershell or cmd is different from the anaconda environment in spyder. One of the differences between conda and pip is that conda installed precompiled packages while pip does not.



来源:https://stackoverflow.com/questions/58054101/dll-load-failed-the-specified-module-could-not-be-found-windows-10-shell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!