一尘不染

导入scikit学习模块时出错

python

我正在尝试从集群模块调用函数,如下所示:

import sklearn
db = sklearn.cluster.DBSCAN()

我收到以下错误:

AttributeError: 'module' object has no attribute 'cluster'

在IPython中,制表符补全似乎可以访问基本,克隆,外部,re,setup_module,sys和警告模块。sklearn目录中没有其他(包括群集)。

遵循以下pbu的建议并使用

from sklearn import cluster

我得到:

Traceback (most recent call last):
  File "test.py", line 2, in <module>
    from sklearn import cluster
  File "C:\Python34\lib\site-packages\sklearn\cluster\__init__.py", line 6, in <module>
    from .spectral import spectral_clustering, SpectralClustering
  File "C:\Python34\lib\site-packages\sklearn\cluster\spectral.py", line 13, in <module>
    from ..utils import check_random_state, as_float_array
  File "C:\Python34\lib\site-packages\sklearn\utils\__init__.py", line 16, in <module>
    from .class_weight import compute_class_weight, compute_sample_weight
  File "C:\Python34\lib\site-packages\sklearn\utils\class_weight.py", line 7, in <module>
    from ..utils.fixes import in1d
  File "C:\Python34\lib\site-packages\sklearn\utils\fixes.py", line 318, in <module>
    from scipy.sparse.linalg import lsqr as sparse_lsqr
  File "C:\Python34\lib\site-packages\scipy\sparse\linalg\__init__.py", line 109, in <module>
    from .isolve import *
  File "C:\Python34\lib\site-packages\scipy\sparse\linalg\isolve\__init__.py", line 6, in <module>
    from .iterative import *
  File "C:\Python34\lib\site-packages\scipy\sparse\linalg\isolve\iterative.py", line 7, in <module>
    from . import _iterative
ImportError: DLL load failed: The specified module could not be found.

我在Windows上使用Python 3.4,scikit-learn 0.16.1。


阅读 158

收藏
2020-12-20

共1个答案

一尘不染

问题是scipy /
numpy安装。我一直在使用http://www.lfd.uci.edu/~gohlke/pythonlibs/中的(通常很出色!)非官方安装程序。从那里卸载/重新安装没有什么区别,但是使用官方安装程序(从http://www.scipy.org/install.html链接)进行安装就可以了。

2020-12-20