sklearn已安装但无法导入

时间:2019-12-26 11:12:58

标签: python tensorflow machine-learning scikit-learn

enter image description here

当我尝试导入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.
>>>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                

2 个答案:

答案 0 :(得分:0)

通过在0.22以下安装sklearn可修复相同的错误。请尝试以下命令。

pip install scikit-learn==0.21.3

答案 1 :(得分:0)

欢迎使用StackOverflow,希望对您有所帮助!

在Windows中,如您所见,DLL与Python软件包有些依赖。您已经安装了scikit-learn,但是可能会遗漏一些相互依赖的地方。

最好安装Anaconda设置。它具有精选的软件包列表,可确保已安装的软件包正常工作。

链接:https://docs.anaconda.com/anaconda/install/windows/