Are you experiencing the ImportError: DLL load failed: The specified module could not be found error on Windows PC? If so, this post will help you. In this post, we will discuss what this error is, its potential causes, and how to fix it.
What does DLL load failed while importing mean?
The ImportError: DLL load failed error basically occurs when importing Python libraries like NumPy, Pandas, PySide2, etc. It is also triggered while installing Python projects on a Windows PC. Another potential scenario for this error is when the specified DLL is unable to load the particular task that is called by a program. One of the affected users has reported the below scenario in which he/she experiences the error:
I’m running Python 3.5.4 on Anaconda and i’m trying to install geopandas. I’ve followed the instructions to install geopandas here – http://geoffboeing.com/2014/09/using-geopandas-windows/ – but whichever way i try i get the same error
Now, there could be different reasons why you may encounter this error. It could be due to corrupted or missing DLL files on your PC. Another reason for the same could be the fact that the correct environment variables are not set on your computer. One more potential cause of this error is an incorrect or incomplete installation of the library you are trying to import. Apart from that, a corrupted Microsoft Visual C++ package can also be a reason for this error.
ImportError: DLL load failed: The specified module could not be found
Here are the methods you can use to fix the “ImportError: DLL load failed: The specified module could not be found” error on your Windows PC:
- Run the System File Checker scan.
- Set up Environment Variables.
- Repair Microsoft Visual C++ Redistributable.
- Reinstall Microsoft Visual C++ Redistributable.
- Reinstall Library.
1] Run the System File Checker scan
As the error is most likely triggered because of missing or corrupted DLL files, you can run a System File Checker (SFC) scan to fix it. System File Checker is an inbuilt command line utility that helps Windows users to scan and repair broken or missing system files that also include DLL files. You can perform an SFC scan to fix the DLL files and then check if the error is resolved.
Here’s how to do that:
First, launch an elevated Command Prompt window and enter the below command:
sfc /scannow
See if the “ImportError: DLL load failed: The specified module could not be found” error is fixed now.
Read: PIP is not recognized as an internal or external command.
2] Set up Environment Variables
It might also be the case that environment variables are not configured correctly on your PC which is why you can facing this error. Hence, if the scenario is applicable, set up environment variables again and see if the error is fixed. Here are the steps to do that:
First, make sure you know what Python distribution you are using like Anaconda.
Now, type system environment inside the Windows search box and then click on Edit the system environment variables.
In the appeared window, press the Environment Variables button. Now, click on the Path variable and then tap on the Edit button.
After that, press the New button inside the Edit environment variable window and enter the below paths one by one:
C:\ProgramData\Anaconda3 C:\ProgramData\Anaconda3\Scripts C:\ProgramData\Anaconda3\Library\bin
The above locations may differ for individuals. So, enter the paths accordingly.
Once done, press the Ok button and exit the System Properties window. Check if the error is now resolved.
See: CDP.dll is either not designed to run on Windows or contains an error.
3] Repair Microsoft Visual C++ Redistributable
If the error still appears, try repairing the Microsoft Visual C++ Redistributable package. It could be a corrupted Visual C++ library causing the error. Hence, repair the package and see if the error has stopped popping up. Here are the steps to do that:
- First, open the Settings app using Win+I and go to the Apps > Installed apps section.
- Now, look for the Microsoft Visual C++ Redistributable package and tap on the three-dot menu button present next to it.
- After that, click on the Modify button and then choose the Repair button in the appeared dialog window.
- Once the process is finished, check if the error is resolved.
Read: Fix Ucrtbase.dll was not found or missing error.
4] Reinstall Microsoft Visual C++ Redistributable
If repairing didn’t work, you can reinstall a fresh and clean version of Visual C++. The corruption might be beyond corruption. So, uninstall Microsoft Visual C++ Redistributable and then reinstall it on your computer to check if the error is fixed.
5] Reinstall Library
The error is mostly triggered while trying to import a library. Now, if this library is not installed correctly or the installation is incomplete or incompatible, the error might be caused. Hence, if the scenario is applicable, you can try reinstalling the problematic library that is causing the error.
Here’s how to do that:
First, find the library due to which you are receiving the ImportError: DLL load failed: The specified module could not be found error. You can check the full error message to identify that.
Now, you can use a simple command to uninstall and then reinstall the library. For example, if you are experiencing this error with the NumPy Python library, use the below commands one by one:
pip uninstall numpy python -m pip install --upgrade pip pip install numpy
Using the above commands in the given sequence, you will be able to install the latest version of NumPy. If you don’t want to install a specific version of NumPy, don’t run the second command in the above order.
Hopefully, you won’t receive the same error now.
How do you fix the specified module could not be found?
To fix The specified module could not be found error on Windows PC, you can use the AutoRuns tool to detect missing entries in the configuration and delete them. Apart from that, you can use a free adware cleaner to clear adware files and fix the sysmenu.dll error. CCleaner can also be used to clear junk files from your computer to fix this error.
Now read: Fix Command python setup.py egg_info failed with error code 1.