来自sklearn import svm ImportError:无法导入名称lsqr

时间:2014-08-01 22:16:36

标签: python scipy scikit-learn

导入svm模块时出现以下错误。我按照说明安装了scipy。这是代码和错误。

>>> from sklearn import svm
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
  File "/root/.local/lib/python2.6/site-packages/sklearn/svm/__init__.py", line 13, in <module>
    from .classes import SVC, NuSVC, SVR, NuSVR, OneClassSVM, LinearSVC
  File "/root/.local/lib/python2.6/site-packages/sklearn/svm/classes.py", line 3, in <module>
    from ..linear_model.base import LinearClassifierMixin, SparseCoefMixin
  File "/root/.local/lib/python2.6/site-packages/sklearn/linear_model/__init__.py", line 12, in <module>
    from .base import LinearRegression
  File "/root/.local/lib/python2.6/site-packages/sklearn/linear_model/base.py", line 23, in <module>
    from scipy.sparse.linalg import lsqr
ImportError: cannot import name lsqr

1 个答案:

答案 0 :(得分:3)

我也遇到过这个问题,它是由scipy版本和scikit-learn版本不匹配引起的,你可以阅读the 'Dependency' section获取scikit learn version 0.13.1或任何其他版本here