从sklearn导入时出现ImportError:无法导入名称check_build。

134
我试图从sklearn导入时遇到以下错误:
>>> from sklearn import svm

Traceback (most recent call last):
  File "<pyshell#17>", line 1, in <module>
   from sklearn import svm
  File "C:\Python27\lib\site-packages\sklearn\__init__.py", line 16, in <module>
   from . import check_build
ImportError: cannot import name check_build

我正在使用Python 2.7,scipy-0.12.0b1超级包,numpy-1.6.0超级包和scikit-learn-0.11。我使用的是Windows 7操作系统。

我查看了几个答案,但没有一个提供解决这个错误的方法。


尝试将scikit-learn更新到当前版本(0.13)。 - adrianp
现在我遇到了以下错误。 - ayush singhal
导入错误:无法导入名称__check_build,而不是check_build。 - ayush singhal
我已经更新到scikit 0.13。 - ayush singhal
你是如何安装sklearn的?你使用的是二进制安装程序还是软件包安装程序(例如easy_install或pip)? - BenDundee
显示剩余4条评论
13个回答

2

对我来说,我正在通过安装最新的Python版本(3.7)从头开始使用Anaconda将现有代码升级到新的设置中。

为此,

from sklearn import cross_validation, 
from sklearn.grid_search import GridSearchCV

to

from sklearn.model_selection import GridSearchCV,cross_validate

0

我曾经遇到过同样的问题,重新安装Anaconda解决了我的问题。


0
在Windows系统中:
我尝试通过命令行删除sklearn:pip uninstall sklearn,然后重新安装它,但是没有成功...
解决方案:
1- open the cmd shell.
2- cd c:\pythonVERSION\scripts
3- pip uninstall sklearn
4- open in the explorer: C:\pythonVERSION\Lib\site-packages
5- look for the folders that contains sklearn and delete them ..
6- back to cmd: pip install sklearn

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接