首页 > 解决方案 > sklearn 已安装但无法导入

问题描述

在此处输入图像描述

当我尝试导入 sklearn 时,出现以下错误。

请查找以下错误跟踪以获取更多详细信息:


C:\Users\Priyanshu\AppData\Local\Programs\Python\Python37-32\Lib\site-packages> pip install sklearn                  Requirement already satisfied: sklearn in c:\users\priyanshu\appdata\local\programs\python\python37-32\lib\site-packages (0.0)
Requirement already satisfied: scikit-learn in c:\users\priyanshu\appdata\local\programs\python\python37-32\lib\site-packages (from sklearn) (0.22)
Requirement already satisfied: numpy>=1.11.0 in c:\users\priyanshu\appdata\local\programs\python\python37-32\lib\site-packages (from scikit-learn->sklearn) (1.17.2)
Requirement already satisfied: joblib>=0.11 in c:\users\priyanshu\appdata\local\programs\python\python37-32\lib\site-packages (from scikit-learn->sklearn) (0.14.1)
Requirement already satisfied: scipy>=0.17.0 in c:\users\priyanshu\appdata\local\programs\python\python37-32\lib\site-packages (from scikit-learn->sklearn) (1.3.1)
PS C:\Users\Priyanshu\AppData\Local\Programs\Python\Python37-32\Lib\site-packages> python                               Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

>>> import sklearn
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Priyanshu\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\sklearn\__init__.py", line 75, in <module>
    from .utils._show_versions import show_versions
  File "C:\Users\Priyanshu\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\sklearn\utils\_show_versions.py", line 12, in <module>
    from ._openmp_helpers import _openmp_parallelism_enabled
ImportError: DLL load failed: The specified module could not be found.
>>>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                

标签: pythontensorflowmachine-learningscikit-learn

解决方案


The same error is fixed by installing sklearn below 0.22. Please try the below command.

pip install scikit-learn==0.21.3

推荐阅读