首页 > 解决方案 > ImportError: DLL load failed: 找不到指定的过程

问题描述

我正在使用 Jupyter 执行以下代码,但出现错误

import pandas as pd
from sklearn.tree import DecisionTreeClassifier 

music_data = pd.read_csv('music.csv')
X = music_data.drop(columns=['genre'])
y = music_data['genre']

model = DecisionTreeClassifier()
model.fit(X,y)
music_data

发生了错误:

ImportError                               Traceback (most recent call last)
<ipython-input-28-7af4ede8a769> in <module>
      1 import pandas as pd
----> 2 from sklearn.tree import DecisionTreeClassifier
      3 
      4 music_data = pd.read_csv('music.csv')
      5 X = music_data.drop(columns=['genre'])

~\Anaconda3\lib\site-packages\sklearn\__init__.py in <module>
     74 else:
     75     from . import __check_build
---> 76     from .base import clone
     77     from .utils._show_versions import show_versions
     78 

~\Anaconda3\lib\site-packages\sklearn\base.py in <module>
     14 
     15 from . import __version__
---> 16 from .utils import _IS_32BIT
     17 
     18 _DEFAULT_TAGS = {

~\Anaconda3\lib\site-packages\sklearn\utils\__init__.py in <module>
     18 from ..exceptions import DataConversionWarning
     19 from .deprecation import deprecated
---> 20 from .validation import (as_float_array,
     21                          assert_all_finite,
     22                          check_random_state, column_or_1d, check_array,

~\Anaconda3\lib\site-packages\sklearn\utils\validation.py in <module>
     19 from numpy.core.numeric import ComplexWarning
     20 
---> 21 from .fixes import _object_dtype_isnan
     22 from .. import get_config as _get_config
     23 from ..exceptions import NonBLASDotWarning

~\Anaconda3\lib\site-packages\sklearn\utils\fixes.py in <module>
     16 import scipy.sparse as sp
     17 import scipy
---> 18 from scipy.sparse.linalg import lsqr as sparse_lsqr  # noqa
     19 
     20 

~\Anaconda3\lib\site-packages\scipy\sparse\linalg\__init__.py in <module>
    114 from .dsolve import *
    115 from .interface import *
--> 116 from .eigen import *
    117 from .matfuncs import *
    118 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.

我正在使用 Python 3.8.0 和 anaconda3,请有人告诉我这里出了什么问题

标签: machine-learningscikit-learnjupyter-notebookanacondasklearn-pandas

解决方案


从错误日志看来,问题出在这一行:

from scipy.sparse.linalg import lsqr as sparse_lsqr

尝试卸载并重新安装scipynumpy

卸载:

pip uninstall numpy scipy

安装:

pip install -U numpy scipy

推荐阅读