Can't import sklearn

20 views
Skip to first unread message

Jonathan Colledge

unread,
Nov 20, 2020, 7:02:27 AM11/20/20
to Anaconda - Public

I just can't import sklearn in Anaconda. I tried it in my Python install before and it didn't work. So I uninstalled all Python, Visual Studio, etc. Then I tried again, and finally decided to give Anaconda a go.

Can anyone help please?

Latest Anaconda is installed for just me. Scikit-learn is installed, but import sklearn gives this:

<ipython-input-1-b7c74cbf5af0> in <module>
----> 1 import sklearn

~\anaconda3\lib\site-packages\sklearn\__init__.py in <module>
     78     from . import _distributor_init  # noqa: F401
     79     from . import __check_build  # noqa: F401
---> 80     from .base import clone
     81     from .utils._show_versions import show_versions
     82

~\anaconda3\lib\site-packages\sklearn\base.py in <module>
     19 from . import __version__
     20 from ._config import get_config
---> 21 from .utils import _IS_32BIT
     22 from .utils.validation import check_X_y
     23 from .utils.validation import check_array

~\anaconda3\lib\site-packages\sklearn\utils\__init__.py in <module>
     21
     22 from .murmurhash import murmurhash3_32
---> 23 from .class_weight import compute_class_weight, compute_sample_weight
     24 from . import _joblib
     25 from ..exceptions import DataConversionWarning

~\anaconda3\lib\site-packages\sklearn\utils\class_weight.py in <module>
      5 import numpy as np
      6
----> 7 from .validation import _deprecate_positional_args
      8
      9

~\anaconda3\lib\site-packages\sklearn\utils\validation.py in <module>
     24 from contextlib import suppress
     25
---> 26 from .fixes import _object_dtype_isnan
     27 from .. import get_config as _get_config
     28 from ..exceptions import NonBLASDotWarning, PositiveSpectrumWarning

~\anaconda3\lib\site-packages\sklearn\utils\fixes.py in <module>
     16 import scipy.sparse as sp
     17 import scipy
---> 18 import scipy.stats
     19 from scipy.sparse.linalg import lsqr as sparse_lsqr  # noqa
     20 from numpy.ma import MaskedArray as _MaskedArray  # TODO: remove in 0.25

~\anaconda3\lib\site-packages\scipy\stats\__init__.py in <module>
    386
    387 """
--> 388 from .stats import *
    389 from .distributions import *
    390 from .morestats import *

~\anaconda3\lib\site-packages\scipy\stats\stats.py in <module>
    178 import scipy.special as special
    179 from scipy import linalg
--> 180 from . import distributions
    181 from . import mstats_basic
    182 from ._stats_mstats_common import (_find_repeats, linregress, theilslopes,

~\anaconda3\lib\site-packages\scipy\stats\distributions.py in <module>
      6 #       instead of `git blame -Lxxx,+x`.
      7 #
----> 8 from ._distn_infrastructure import (entropy, rv_discrete, rv_continuous,
      9                                     rv_frozen)
     10

~\anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py in <module>
     21
     22 # for root finding for continuous distribution ppf, and max likelihood estimation
---> 23 from scipy import optimize
     24
     25 # for functions of continuous distributions (e.g. moments, entropy, cdf)

~\anaconda3\lib\site-packages\scipy\optimize\__init__.py in <module>
    385 """
    386
--> 387 from .optimize import *
    388 from ._minimize import *
    389 from ._root import *

~\anaconda3\lib\site-packages\scipy\optimize\optimize.py in <module>
     34                          line_search_wolfe2 as line_search,
     35                          LineSearchWarning)
---> 36 from ._numdiff import approx_derivative
     37 from scipy._lib._util import getfullargspec_no_self as _getfullargspec
     38 from scipy._lib._util import MapWrapper

~\anaconda3\lib\site-packages\scipy\optimize\_numdiff.py in <module>
      4 from numpy.linalg import norm
      5
----> 6 from scipy.sparse.linalg import LinearOperator
      7 from ..sparse import issparse, csc_matrix, csr_matrix, coo_matrix, find
      8 from ._group_columns import group_dense, group_sparse

~\anaconda3\lib\site-packages\scipy\sparse\linalg\__init__.py in <module>
    112 from .dsolve import *
    113 from .interface import *
--> 114 from .eigen import *
    115 from .matfuncs import *
    116 from ._onenormest import *

~\anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\__init__.py in <module>
      7
      8 """
----> 9 from .arpack import *
     10 from .lobpcg import *
     11

~\anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\__init__.py in <module>
     18
     19 """
---> 20 from .arpack import *

~\anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\arpack.py in <module>
     41 __all__ = ['eigs', 'eigsh', 'svds', 'ArpackError', 'ArpackNoConvergence']
     42
---> 43 from . import _arpack
     44 arpack_int = _arpack.timing.nbx.dtype
     45

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

Jonathan Colledge

unread,
Nov 20, 2020, 3:25:39 PM11/20/20
to Anaconda - Public, Jonathan Colledge

$> conda remove --force numpy, scipy
$> pip install numpy
$> pip install scipy

(Actually, it didn't remove numpy, but it worked)
Reply all
Reply to author
Forward
0 new messages