Problem
I'm starting to learn machine learning, one of the course examples uses scikit-learn package, and we are required to install and apply what we have done so far. However, I tried to install the package like the course instructor suggested by pip install scikit-learn during the installation, numpy, scipy, threadpoolctl, and joblib were installed as a prerequisite for scikit-learn. So far so good and everything were installed smoothly.
But, after that, when I try to import the scikit-learn package like
from sklearn.tree import DecisionTreeRegressor
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\hema-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\sklearn\__init__.py", line 74, in <module>
from .base import clone
File "C:\Users\hema-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\sklearn\base.py", line 20, in <module>
from .utils import _IS_32BIT
File "C:\Users\hema-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\sklearn\utils\__init__.py", line 18, in <module>
from scipy.sparse import issparse
File "C:\Users\hema-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\scipy\__init__.py", line 136, in <module>
from . import _distributor_init
File "C:\Users\hema-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\scipy\_distributor_init.py", line 61, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2288.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
The case is not only for the above import line, even if I try to import sklearn only I get the same error.
After some research and as it's recommended by the package page, I've used a separate venv and install the package there along with it's dependencies to avoid conflicts. Unfortunately, I'm still getting the same error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Machine Learning\ml_demo\machine_learning_env\lib\site-packages\sklearn\__init__.py", line 80, in <module>
from .base import clone
File "D:\Machine Learning\ml_demo\machine_learning_env\lib\site-packages\sklearn\base.py", line 21, in <module>
from .utils import _IS_32BIT
File "D:\Machine Learning\ml_demo\machine_learning_env\lib\site-packages\sklearn\utils\__init__.py", line 20, in <module>
from scipy.sparse import issparse
File "D:\Machine Learning\ml_demo\machine_learning_env\lib\site-packages\scipy\__init__.py", line 136, in <module>
from . import _distributor_init
File "D:\Machine Learning\ml_demo\machine_learning_env\lib\site-packages\scipy\_distributor_init.py", line 61, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2288.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
What else did I try?
- I tried reinstalling.
- I also tried installing the wheel version of the packages downloaded from here. However, another problem arose, which is when I try installing the wheel by
pip install scikit_learn-0.23.1-cp39-cp39-win_amd64.whlI get the following error:
ERROR: scikit_learn-0.23.1-cp39-cp39-win_amd64.whl is not a supported wheel on this platform.
I did solve this problem nonetheless, by using the --no-binary option as it's stated here.
My environment
- I'm using Python 3.7.8
- OS Windows10
- A list of the venv packages (thought might help)
joblib 0.16.0
numpy 1.19.1
pip 20.1.1
scikit-learn 0.23.1
scipy 1.5.2
setuptools 47.1.0
threadpoolctl 2.1.0