How to resolve "ImportError: DLL load failed:" on Python?
Question:
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?
Answers:
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.)
I don’t know but I opened the adminstrator cmd
if don’t know just hover over command promp and right click and you’ll see the option of open in admistrator mode click over it
just uninstall using pip uninstall package_name and don’t close because the package_will be cached down and when you again command pip install package_name it should work ,just because it worked for me LOL
if you close it you have to download it again
like ffpyplayer is of 25 mbs so why to do that
You can try to activate an enviroment. Activating environments is essential to making the software in the environments work well. Activation entails two primary functions: adding entries to PATH for the environment and running any activation scripts that the environment may contain.
(Only work on conda 4.6 and later versions)
To activate, execute this first on cmd:
conda activate
The, run the jupyter notebook on cmd too
jupyter notebook
This work for me when I was trying to use "seaborn" and anothers packages like numpy, sklearn, and so on.
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")
So I faced a similar issue; uninstalling and reinstalling Anaconda was the only way I found to fix it. To remove Anaconda and all its residual files I used the iobit uninstaller software, you can download it here:
This is an old question, and sadly pops up in search results. The solution that actually works:
If re-installing python didn’t work, you simply need to update pywin32
pip install pywin32==300
Read more here:
ImportError: DLL load failed while importing shell
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?
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.)
I don’t know but I opened the adminstrator cmd
if don’t know just hover over command promp and right click and you’ll see the option of open in admistrator mode click over it
just uninstall using pip uninstall package_name and don’t close because the package_will be cached down and when you again command pip install package_name it should work ,just because it worked for me LOL
if you close it you have to download it again
like ffpyplayer is of 25 mbs so why to do that
You can try to activate an enviroment. Activating environments is essential to making the software in the environments work well. Activation entails two primary functions: adding entries to PATH for the environment and running any activation scripts that the environment may contain.
(Only work on conda 4.6 and later versions)
To activate, execute this first on cmd:
conda activate
The, run the jupyter notebook on cmd too
jupyter notebook
This work for me when I was trying to use "seaborn" and anothers packages like numpy, sklearn, and so on.
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")
So I faced a similar issue; uninstalling and reinstalling Anaconda was the only way I found to fix it. To remove Anaconda and all its residual files I used the iobit uninstaller software, you can download it here:
This is an old question, and sadly pops up in search results. The solution that actually works:
If re-installing python didn’t work, you simply need to update pywin32
pip install pywin32==300
Read more here:
ImportError: DLL load failed while importing shell