[英]WinError 126 The specified module could not be found, when importing scikit-learn package?
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.我开始学习机器学习,其中一个课程示例使用 scikit-learn package,我们需要安装和应用我们迄今为止所做的。 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. 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
但是,在那之后,当我尝试导入 scikit-learn package
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.这种情况不仅适用于上述导入行,即使我尝试仅
import sklearn
我也会遇到相同的错误。
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.经过一些研究,并且正如package 页面所推荐的那样,我使用了一个单独的
venv
并在那里安装了 package 及其依赖项以避免冲突。 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
pip install scikit_learn-0.23.1-cp39-cp39-win_amd64.whl
I get the following error: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.
I did solve this problem nonetheless, by using the --no-binary
option as it's stated here .尽管如此,我确实通过使用
--no-binary
选项解决了这个问题,正如这里所说的那样。
joblib 0.16.0
作业库 0.16.0
numpy 1.19.1numpy 1.19.1
pip 20.1.1pip 20.1.1
scikit-learn 0.23.1scikit-learn 0.23.1
scipy 1.5.2scipy 1.5.2
setuptools 47.1.0安装工具 47.1.0
threadpoolctl 2.1.0线程池ctl 2.1.0
First, you should enter this code in your shell,Check if your pip version does not support cp39.首先,您应该在您的 shell 中输入此代码,检查您的 pip 版本是否不支持 cp39。
import pip._internal;print(pip._internal.pep425tags.get_supported())
Maybe you will get some resonpes, something like this:也许你会得到一些回应,像这样:
[('cp38', 'cp38m', 'win_amd64'), ('cp38', 'none', 'win_amd64'), ('py3', 'none', 'win_amd64'), ('cp38', 'none', 'any'), ('cp3', 'none', 'any'), ('py38', 'none', 'any'), ('py3', 'none', 'any'), ('py37', 'none', 'any'), ('py36', 'none', 'any'), ('py35', 'none', 'any'), ('py34', 'none', 'any'), ('py33', 'none', 'any'), ('py32', 'none', 'any'), ('py31', 'none', 'any'), ('py30', 'none', 'any')]
So,If your python pip does not support cp39, then please choose a downgrade version.因此,如果您的 python pip 不支持 cp39,请选择降级版本。 Forexample:
例如:
scikit_learn‑0.23.2‑cp38‑cp38‑win_amd64.whl
scikit_learn‑0.23.2‑cp38‑cp38‑win_amd64.whl
And then, When you downloaded this profile,copy to your site-page, Use this command in your Terminal.然后,当您下载此配置文件时,复制到您的站点页面,在您的终端中使用此命令。
pip install scikit_learn‑0.23.2‑cp38‑cp38‑win_amd64.whl
i think it will be working!我想它会起作用的! Hope to help you!
希望能帮到你!
Scikit-learn 0.20 was the last version to support Python 2.7 and Python 3.4. Scikit-learn 0.20 是支持 Python 2.7 和 Python 3.4 的最后一个版本。 Scikit-learn 0.21 supported Python 3.5-3.7.
Scikit-learn 0.21 支持 Python 3.5-3.7。 Scikit-learn 0.22 supported Python 3.5-3.8.
Scikit-learn 0.22 支持 Python 3.5-3.8。 Scikit-learn now requires Python 3.6 or newer.
Scikit-learn 现在需要 Python 3.6 或更新版本。
So i think you should update your python upto 3.9所以我认为你应该将你的 python 更新到 3.9
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.