简体   繁体   中英

sklearn installed but unable to import

在此处输入图片说明

When I try to import sklearn it is giving the following error.

Please find the below error trace for more details:


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.
>>>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                

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

pip install scikit-learn==0.21.3

Welcome to StackOverflow & I hope this helps!

In windows, as you can see DLL s are of a bit dependency with Python Packages. You have installed scikit-learn but there could be some interdependencies you got missed.

Prefer installing Anaconda setup. It has a curated list of packages that ensures that installed packages work.

Link: https://docs.anaconda.com/anaconda/install/windows/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM