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

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

If anyone comes across this issue in Python > 3.8 with Windows, dlls 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.

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

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

Thats it 🙂 – it is now working! (it also fixed the error for all of the other libraries as well, such as sklearn, matplotlib etc.)

Leave a Reply

Your email address will not be published. Required fields are marked *