【发布时间】:2020-11-24 03:50:10
【问题描述】:
问题
我开始学习机器学习,其中一个课程示例使用 scikit-learn 包,我们需要安装和应用我们迄今为止所做的。但是,我在安装过程中尝试像pip install scikit-learn 建议的课程讲师一样安装软件包,安装了numpy、scipy、threadpoolctl 和joblib 作为scikit-learn 的先决条件。到目前为止一切顺利,一切安装顺利。
但是,在那之后,当我尝试像导入 scikit-learn 包时
from sklearn.tree import DecisionTreeRegressor
我收到以下错误:
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
这种情况不仅适用于上述导入行,即使我尝试 import sklearn 也只有我得到同样的错误。
经过一些研究并按照package page 的建议,我使用了一个单独的venv 并在那里安装了软件包及其依赖项以避免冲突。不幸的是,我仍然遇到同样的错误:
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
我还尝试了什么?
- 我尝试重新安装。
- 我还尝试安装从here 下载的软件包的wheel 版本。但是,出现了另一个问题,即当我尝试通过
pip install scikit_learn-0.23.1-cp39-cp39-win_amd64.whl安装轮子时,出现以下错误:
ERROR: scikit_learn-0.23.1-cp39-cp39-win_amd64.whl is not a supported wheel on this platform.
尽管如此,我确实通过使用 --no-binary 选项解决了这个问题,正如它所说的 here。
我的环境
- 我使用的是 Python 3.7.8
- 操作系统 Windows10
- venv 软件包列表(可能会有所帮助)
joblib 0.16.0
numpy 1.19.1
点 20.1.1
scikit-learn 0.23.1
scipy 1.5.2
安装工具 47.1.0
线程池ctl 2.1.0
【问题讨论】:
标签: python scikit-learn