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?
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")
I have managed to resolve the problem by reinstalling Python. First, I have uninstalled Python (like any other program in Windows). Then I have installed Anaconda distribution of Python. The problem is not present anymore.
I just encountered this exact problem and was struggling to solve it. I tried to reinstall anaconda, I reinstalled the relevant packages, I changed my environment - BUT NOTHING WORKED! eventually, after few hours, I managed to solve this problem with some few easy steps as described here :)
just type in the command line (one code-line at a time):
conda install numpy
then, conda install scipy
then, pip install -U seaborn
then, pip install -U numpy
and finally, pip install -U scipy
That's it :) - it is now working! (it also fixed the error for all of the other libraries as well, such as sklearn, matplotlib etc.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With