Error when calling scikit-learn using AMD64 build

2020-07-23 03:35发布

问题:

I am getting this error on this line:

from sklearn.ensemble import RandomForestClassifier

The error log is:

Traceback (most recent call last):
  File "C:\workspace\KaggleDigits\KaggleDigits.py", line 5, in <module>
    from sklearn.ensemble import RandomForestClassifier
  File "C:\Python27\lib\site-packages\sklearn\ensemble\__init__.py", line 7, in <module>
    from .forest import RandomForestClassifier
  File "C:\Python27\lib\site-packages\sklearn\ensemble\forest.py", line 47, in <module>
    from ..feature_selection.selector_mixin import SelectorMixin
  File "C:\Python27\lib\site-packages\sklearn\feature_selection\__init__.py", line 7, in <module>
    from .univariate_selection import chi2
  File "C:\Python27\lib\site-packages\sklearn\feature_selection\univariate_selection.py", line 13, in <module>
    from scipy import stats
  File "C:\Python27\lib\site-packages\scipy\stats\__init__.py", line 320, in <module>
    from .stats import *
  File "C:\Python27\lib\site-packages\scipy\stats\stats.py", line 241, in <module>
    import scipy.special as special
  File "C:\Python27\lib\site-packages\scipy\special\__init__.py", line 529, in <module>
    from ._ufuncs import *
ImportError: DLL load failed: The specified module could not be found.

After installing:

  • Python 2.7.4 for Windows x86-64
  • scipy-0.12.0.win-amd64-py2.7.‌exe (from here)
  • numpy-unoptimized-1.7.1.win-amd64-py2.7.‌exe (from here)
  • scikit-learn-0.13.1.win-amd64-py2.7.‌exe (from here)

Anybody know why this is happening and how to solve it ?

回答1:

As Christoph Gohlke mentioned on his download page, the scikit-learn downloadable from his website requires Numpy-MKL. Therefore I made a mistake by using Numpy-Unoptimized.

The link to his Numpy-MKL is statically linked to the Intel's MKL and therefore you do not need any additional download (no need to download Intel's MKL).



回答2:

This is a little late, but for those like me, download these from the official Microsoft website.

After that restart your interpreter/console and it should work.



回答3:

This problem happened to me when I use scipy 0.12. After I changed to scipy 0.11, the problem was gone.