AttributeError:模块“ scipy”在sklearn / utils / fixes.py中没有属性“ sparse”

时间:2019-04-19 10:03:32

标签: python scikit-learn scipy

我更新了sklearn,scipy(以前一切正常)。当前版本:

python: 3.6.8
scikit-learn 0.20.3
numpy: 1.16.2
scipy: 1.2.1

结果,该错误开始发生:

  File "....projects/Test.py", line 8, in <module>
    from sklearn import datasets

  File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\__init__.py", line 64, in <module>
    from .base import clone

  File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\base.py", line 14, in <module>
    from .utils.fixes import signature

  File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\utils\__init__.py", line 16, in <module>
    from .fixes import _Sequence as Sequence

  File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\utils\fixes.py", line 20, in <module>
    import scipy.sparse as sp

AttributeError: module 'scipy' has no attribute 'sparse'

我尝试重新安装sklearn,scipy,但没有帮助。

无效的示例代码:

from sklearn import datasets

iris = datasets.load_iris()

1 个答案:

答案 0 :(得分:0)

重新安装scikit-learn,scipy和numpy时,问题已解决