简体   繁体   中英

Sklearn __init__.py error

I am receiving an error when trying to install Sklearn via pip from a .whl file.

I have read all of the existing comments about uninstalling Sklearn and going to http://www.lfd.uci.edu/~gohlke/pythonlibs/ to download the file after installing Numpy & Scipy.

For whatever reason, I keeping getting the following error:

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    import sklearn
  File "C:\Users\username\AppData\Local\Programs\Python\Python35\lib\site-packages\sklearn\__init__.py", line 57, in <module>
    from .base import clone
  File "C:\Users\username\AppData\Local\Programs\Python\Python35\lib\site-packages\sklearn\base.py", line 9, in <module>
    from scipy import sparse
  File "C:\Users\username\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\sparse\__init__.py", line 214, in <module>
    from .csr import *
  File "C:\Users\username\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\sparse\csr.py", line 13, in <module>
    from ._sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
ImportError: DLL load failed: The specified module could not be found.

I have windows 7 with Python 3.5 64-bit installed. I can import Numpy & Scipy without issue just Sklearn will not work.

I have tried to run the setup.py file as well but that has not fixed the issue.

I had the same error when trying to import scikit-learn inside a python script.

My config: Python v3.4 ; Platform = Windows 10.

Here what I've done to resolve the issue:

  • I uninstall numpy, scipy and scikit-learn via pip.
  • I install numpy+mkl with the wheel "numpy‑1.12.0+mkl‑cp34‑cp34m‑win_amd64.whl" via pip
  • I reinstall scipy with the wheel "scipy‑0.19.0rc2‑cp34‑cp34m‑win_amd64.whl" via pip
  • I reinstall scikit-learn via pip

Notes:

Here is the list of all the libs I have:

$ pip list --format=columns
Package             Version
------------------- ----------
appdirs             1.4.2
backports-abc       0.5
bleach              1.5.0
colorama            0.3.7
cycler              0.10.0
decorator           4.0.11
entrypoints         0.2.2
html5lib            0.9999999
ipykernel           4.5.2
ipython             5.3.0
ipython-genutils    0.1.0
ipywidgets          5.2.2
Jinja2              2.9.5
jsonschema          2.6.0
jupyter             1.0.0
jupyter-client      5.0.0
jupyter-console     5.1.0
jupyter-core        4.3.0
MarkupSafe          0.23
matplotlib          2.0.0
mistune             0.7.3
mpmath              0.19
nbconvert           5.1.1
nbformat            4.3.0
nose                1.3.7
notebook            4.4.1
numpy               1.12.0+mkl
packaging           16.8
pandas              0.19.2
pandocfilters       1.4.1
pickleshare         0.7.4
pip                 9.0.1
prompt-toolkit      1.0.13
Pygments            2.2.0
pyparsing           2.1.10
python-dateutil     2.6.0
pytz                2016.10
pyzmq               16.0.2
qtconsole           4.2.1
scikit-learn        0.18.1
scipy               0.19.0rc2
setuptools          34.3.0
simplegeneric       0.8.1
six                 1.10.0
sympy               1.0
testpath            0.3
tornado             4.4.2
traitlets           4.3.2
wcwidth             0.1.7
widgetsnbextension  1.2.6
win-unicode-console 0.5

Hope it's help!

As an alternative to Ant0nin's solution, I suggest you to install Anaconda package:

https://www.continuum.io/downloads

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