Shivam...
Shivam...

Reputation: 424

Scikit learn DLL load failed in anaconda

I am getting an import error while trying to import sklearn package in anaconda jupyter notebook. The import statement is

from sklearn.model_selection import train_test_split

The stack trace of the error is

    ImportError                               Traceback (most recent call last)
<ipython-input-2-fc66e67e2be3> in <module>
      2 import numpy as np
      3 import matplotlib.pyplot as plt
----> 4 from sklearn.model_selection import train_test_split
      5 from sklearn.preprocessing import LabelEncoder
      6 from keras.models import Model

~\Anaconda3\lib\site-packages\sklearn\__init__.py in <module>
     62 else:
     63     from . import __check_build
---> 64     from .base import clone
     65     from .utils._show_versions import show_versions
     66 

~\Anaconda3\lib\site-packages\sklearn\base.py in <module>
     11 from scipy import sparse
     12 from .externals import six
---> 13 from .utils.fixes import signature
     14 from . import __version__
     15 

~\Anaconda3\lib\site-packages\sklearn\utils\__init__.py in <module>
     14 from . import _joblib
     15 from ..exceptions import DataConversionWarning
---> 16 from .fixes import _Sequence as Sequence
     17 from .deprecation import deprecated
     18 from .validation import (as_float_array,

~\Anaconda3\lib\site-packages\sklearn\utils\fixes.py in <module>
     90     from ._scipy_sparse_lsqr_backport import lsqr as sparse_lsqr
     91 else:
---> 92     from scipy.sparse.linalg import lsqr as sparse_lsqr  # noqa
     93 
     94 

~\Anaconda3\lib\site-packages\scipy\sparse\linalg\__init__.py in <module>
    115 from .dsolve import *
    116 from .interface import *
--> 117 from .eigen import *
    118 from .matfuncs import *
    119 from ._onenormest import *

~\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\__init__.py in <module>
      9 from __future__ import division, print_function, absolute_import
     10 
---> 11 from .arpack import *
     12 from .lobpcg import *
     13 

~\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\__init__.py in <module>
     20 from __future__ import division, print_function, absolute_import
     21 
---> 22 from .arpack import *

~\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\arpack.py in <module>
     43 __all__ = ['eigs', 'eigsh', 'svds', 'ArpackError', 'ArpackNoConvergence']
     44 
---> 45 from . import _arpack
     46 import numpy as np
     47 import warnings

ImportError: DLL load failed: The specified procedure could not be found.

Can anyone help.

Upvotes: 3

Views: 3868

Answers (2)

Noize
Noize

Reputation: 11

This thread is older, but maybe someone runs into the same issue. In my case removing (or renaming them to .bak) all MKL-libraries from Windows/system32 helped:

mkl_core.dll
mkl_def.dll
mkl_intel_thread.dll
libiomp5md.dll
libmmd.dll

Also check Windows/SysWOW64 for these files.

In my case I deleted the first 4 files, like some posts in other forums suggest, but still got the "DLL load failed: The specified procedure could not be found"-Error. Using dependencywalker I figured out, that the libmmd.dll also had to be removed.

Upvotes: 1

StephenRUK
StephenRUK

Reputation: 41

I also faced this error and solved it through a lot of trial and error. It was strange that I could import sklearn.metrics successfully in the python shell, but not in the Jupyter Notebook.

Finally, I was able to resolve the issue by simultaneously reinstalling scipy and related packages with anaconda: conda install numpy numpy-base scipy scikit-learn mkl --force-reinstall

I found this StackOverflow post useful: Python scipy module import error due to missing ._ufuncs dll

Upvotes: 3

Related Questions