0

here I'm encountering strange behavior with VSCode Jupyter notebook! i can't import from sklearn.model_selection import KFold cause it give me ImportError like this:

ImportError                               Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_30716/370171074.py in <module>
----> 1 from sklearn.model_selection import KFold

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

~\Anaconda3\lib\site-packages\sklearn\base.py in <module>
     15 from . import __version__
     16 from ._config import get_config
---> 17 from .utils import _IS_32BIT
     18 from .utils._tags import (
     19     _DEFAULT_TAGS,

~\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, parse_version
     27 from .. import get_config as _get_config
     28 from ..exceptions import PositiveSpectrumWarning

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

~\Anaconda3\lib\site-packages\scipy\stats\__init__.py in <module>
    389 
    390 """
--> 391 from .stats import *
    392 from .distributions import *
    393 from .morestats import *

~\Anaconda3\lib\site-packages\scipy\stats\stats.py in <module>
    172 from numpy import array, asarray, ma
    173 
--> 174 from scipy.spatial.distance import cdist
    175 from scipy.ndimage import measurements
    176 from scipy._lib._util import (_lazywhere, check_random_state, MapWrapper,

~\Anaconda3\lib\site-packages\scipy\spatial\__init__.py in <module>
     96 from .kdtree import *
     97 from .ckdtree import *
---> 98 from .qhull import *
     99 from ._spherical_voronoi import SphericalVoronoi
    100 from ._plotutils import *

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

But when i try this in my CMD (Command Prompt), every thing is okey ! like this : Importing KFold from model_selection of sklearn

so how can i fix this problem? any kind of help would be appreciated!

Shayan
  • 5,165
  • 4
  • 16
  • 45

1 Answers1

1

Which python interpreter you take in the CMD? You can try to switch to it in Jupyter.

It has some problems with the scipy package in your conda environment.

You can try this:

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

You can refer to this page for more details.

Steven-MSFT
  • 7,438
  • 1
  • 5
  • 13
  • Thanks ! it worked... ! i don't know how can i figure out about the interpreter that is taken in CMD! how can i know that? Also Thanks for your referencing ! – Shayan Jul 16 '21 at 05:10
  • 1
    @Shayan you can type in 'where python' command in the cmd, the first one is the python interpreter you are taking. – Steven-MSFT Jul 16 '21 at 05:38