'ImportError: DLL load failed: The specified module could not be found' when importing sklearn
Question:
Python version: 3.5.2
I installed sklearn and some other packages form pip. All of them were installed successfully except sklearn so, I downloaded the wheel and installed it from here. It was successfully installed but when i tried to import it in order to check correct installation, I got tons of errors:
Traceback (most recent call last):
File "C:MyFilesProgramsPythonPlayGround.py", line 1, in
import sklearn
File "C:UsersVaibhav AcharyaAppDataLocalProgramsPythonPython35libsite-packagessklearn_init_.py", line 134, in
from .base import clone
File "C:UsersVaibhav AcharyaAppDataLocalProgramsPythonPython35libsite-packagessklearnbase.py", line 12, in
from .utils.fixes import signature
File "C:UsersVaibhav AcharyaAppDataLocalProgramsPythonPython35libsite-packagessklearnutils_init_.py", line 11, in
from .validation import (as_float_array,
File "C:UsersVaibhav AcharyaAppDataLocalProgramsPythonPython35libsite-packagessklearnutilsvalidation.py", line 18, in
from ..utils.fixes import signature
File "C:UsersVaibhav AcharyaAppDataLocalProgramsPythonPython35libsite-packagessklearnutilsfixes.py", line 144, in
from scipy.sparse.linalg import lsqr as sparse_lsqr # noqa
File "C:UsersVaibhav AcharyaAppDataLocalProgramsPythonPython35libsite-packagesscipysparselinalg_init_.py", line 114, in
from .isolve import *
File "C:UsersVaibhav AcharyaAppDataLocalProgramsPythonPython35libsite-packagesscipysparselinalgisolve_init_.py", line 6, in
from .iterative import *
File "C:UsersVaibhav AcharyaAppDataLocalProgramsPythonPython35libsite-packagesscipysparselinalgisolveiterative.py", line 7, in
from . import _iterative
ImportError: DLL load failed: The specified module could not be found.
And the code was just:
import sklearn
I have already checked correct version of wheel package which I have downloaded.
How can I correct it and why it is occurring?
Answers:
Various things need to be checked:
- Check numpy, scipy installation versions.
- If they are correct then try to import numpy and scipy.
- If they getting imported correctly, then clear your
temp(c:/users/username/Appdata/local/temp)
folder. Restart the machine and try again.
- Still if doesn’t work, then uninstall scipy, numpy , sklearn and
reinstall the proper wheel files
The following steps solved my problem :
- Uninstalling numpy, sklearn and scipy.
- Downloading numpy+mkl and scipy from here.
- Firstly installing numpy+mkl and then scipy.
- Installing sklearn from pip.
Download and install numpy+mkl file.
Currently you might have installed only the numpy file.
-
-
Download the corresponding wheel file in which is suitable for your python installation
-
pip install "/path_to_thefile/numpy-1.14.6+mkl-cp36-cp36m-win_amd64.whl"
This should help you
Python version: 3.5.2
I installed sklearn and some other packages form pip. All of them were installed successfully except sklearn so, I downloaded the wheel and installed it from here. It was successfully installed but when i tried to import it in order to check correct installation, I got tons of errors:
Traceback (most recent call last):
File "C:MyFilesProgramsPythonPlayGround.py", line 1, in
import sklearn
File "C:UsersVaibhav AcharyaAppDataLocalProgramsPythonPython35libsite-packagessklearn_init_.py", line 134, in
from .base import clone
File "C:UsersVaibhav AcharyaAppDataLocalProgramsPythonPython35libsite-packagessklearnbase.py", line 12, in
from .utils.fixes import signature
File "C:UsersVaibhav AcharyaAppDataLocalProgramsPythonPython35libsite-packagessklearnutils_init_.py", line 11, in
from .validation import (as_float_array,
File "C:UsersVaibhav AcharyaAppDataLocalProgramsPythonPython35libsite-packagessklearnutilsvalidation.py", line 18, in
from ..utils.fixes import signature
File "C:UsersVaibhav AcharyaAppDataLocalProgramsPythonPython35libsite-packagessklearnutilsfixes.py", line 144, in
from scipy.sparse.linalg import lsqr as sparse_lsqr # noqa
File "C:UsersVaibhav AcharyaAppDataLocalProgramsPythonPython35libsite-packagesscipysparselinalg_init_.py", line 114, in
from .isolve import *
File "C:UsersVaibhav AcharyaAppDataLocalProgramsPythonPython35libsite-packagesscipysparselinalgisolve_init_.py", line 6, in
from .iterative import *
File "C:UsersVaibhav AcharyaAppDataLocalProgramsPythonPython35libsite-packagesscipysparselinalgisolveiterative.py", line 7, in
from . import _iterativeImportError: DLL load failed: The specified module could not be found.
And the code was just:
import sklearn
I have already checked correct version of wheel package which I have downloaded.
How can I correct it and why it is occurring?
Various things need to be checked:
- Check numpy, scipy installation versions.
- If they are correct then try to import numpy and scipy.
- If they getting imported correctly, then clear your
temp(c:/users/username/Appdata/local/temp)
folder. Restart the machine and try again. - Still if doesn’t work, then uninstall scipy, numpy , sklearn and
reinstall the proper wheel files
The following steps solved my problem :
- Uninstalling numpy, sklearn and scipy.
- Downloading numpy+mkl and scipy from here.
- Firstly installing numpy+mkl and then scipy.
- Installing sklearn from pip.
Download and install numpy+mkl file.
Currently you might have installed only the numpy file.
-
Download the corresponding wheel file in which is suitable for your python installation
-
pip install "/path_to_thefile/numpy-1.14.6+mkl-cp36-cp36m-win_amd64.whl"
This should help you