Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
962 views
in Technique[技术] by (71.8m points)

pip - How to resolve "ImportError: DLL load failed:" on Python?

Recently I start to get ImportError: DLL load failed: error when I import different libraries (for example scikit-learn or scipy and some others).

My assumptions is that I have broken something when I was trying to pip install opencv.

So, my question is how to resolve this problem that seems to be not library specific?

Can I pip install DLL or something like that? Can I just reinstall the whole Python? I am working on Windows. My version of Python is Python 2.7.10 :: Anaconda 2.3.0 (64-bit).

ADDED

If I print sys.path I get this:

['',
 'C:\Anaconda\Scripts',
 'C:\Anaconda\python27.zip',
 'C:\Anaconda\DLLs',
 'C:\Anaconda\lib',
 'C:\Anaconda\lib\plat-win',
 'C:\Anaconda\lib\lib-tk',
 'C:\Anaconda',
 'C:\Anaconda\lib\site-packages',
 'C:\Anaconda\lib\site-packages\Sphinx-1.3.1-py2.7.egg',
 'C:\Anaconda\lib\site-packages\cryptography-0.9.1-py2.7-win-amd64.egg',
 'C:\Panda3D-1.9.2-x64',
 'C:\Panda3D-1.9.2-x64\bin',
 'C:\Anaconda\lib\site-packages\win32',
 'C:\Anaconda\lib\site-packages\win32\lib',
 'C:\Anaconda\lib\site-packages\Pythonwin',
 'C:\Anaconda\lib\site-packages\setuptools-17.1.1-py2.7.egg',
 'C:\Anaconda\lib\site-packages\IPython\extensions',
 'C:\Users\myname\.ipython']

What worries me is that there is a mixture of 32 and 64 versions. Another thing, maybe I just have different Pythons and I just need to call the proper one?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If anyone comes across this issue in Python > 3.8 with Windows, dll's are only loaded from trusted locations https://docs.python.org/3/whatsnew/3.8.html#ctypes This can be fixed by adding the dll path using os.add_dll_directory("PATH_TO_DLL")


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...