"DLL load failed: The specified module could not be found" 从 sklearn 导入 "kfold" 时出错
"DLL load failed: The specified module could not be found" error in importing "kfold" from sklearn
我在 VSCode Jupyter notebook 上遇到了奇怪的行为!
我无法导入 from sklearn.model_selection import KFold
因为它给我这样的 ImportError:
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.
但是 当我在我的 CMD(命令提示符)中尝试这个时,一切都很好!像这样 :
那么我该如何解决这个问题呢?任何形式的帮助将不胜感激!
您在 CMD 中使用哪个 python 解释器?你可以尝试在Jupyter中切换到它。
您的 conda 环境中的 scipy
包存在一些问题。
你可以试试这个:
$> conda remove --force scipy
$> pip install scipy
您可以参考这篇page了解更多详情。
我在 VSCode Jupyter notebook 上遇到了奇怪的行为!
我无法导入 from sklearn.model_selection import KFold
因为它给我这样的 ImportError:
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.
但是 当我在我的 CMD(命令提示符)中尝试这个时,一切都很好!像这样 :
那么我该如何解决这个问题呢?任何形式的帮助将不胜感激!
您在 CMD 中使用哪个 python 解释器?你可以尝试在Jupyter中切换到它。
您的 conda 环境中的 scipy
包存在一些问题。
你可以试试这个:
$> conda remove --force scipy
$> pip install scipy
您可以参考这篇page了解更多详情。