1

I am using Python 2.7.10 and have installed scikit-0.15.2 using pip and i already have "numpy-1.1.10" and "scipy-0.16.0" installed and it works fine but when i try to import TfidfVectorizer from sklearn to construct a term document matrix with tf-idf values

from sklearn.feature_extraction.text import TfidfVectorizer

i get an error:

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

I have already gone through the earlier post and tried the solutions but it didn't work.

Community
  • 1
  • 1
user2471313
  • 63
  • 1
  • 3
  • 10
  • 3
    Please see: http://stackoverflow.com/questions/15274696/importerror-in-importing-from-sklearn-cannot-import-name-check-build – WilHall Oct 18 '15 at 00:48
  • Thanks for the reply.I have already gone through that post and worked on the solutions mentioned, but still i keep getting the same error. – user2471313 Oct 18 '15 at 00:49
  • 1
    Can you please verify that `import scipy` works from your script? – WilHall Oct 18 '15 at 00:52
  • I havent used scipy in my scripts just sklearn – user2471313 Oct 18 '15 at 00:55
  • 1
    Right, but verifying that `import scipy` works will verify that you have it installed, and that the Python interpreter you are running the script in is able to find the library. – WilHall Oct 18 '15 at 00:57
  • I have used import scipy and the script ran successfully intimating that scipy works fine – user2471313 Oct 18 '15 at 00:59
  • Have you tried uninstalling each of the libraries and then re-installing scikit-0.15.2 using pip? – rabbit Oct 18 '15 at 01:50
  • Yes, i did reinstall all the libraries and am still getting the same error when i use sklearn – user2471313 Oct 18 '15 at 02:09

2 Answers2

4

For windows user try to install numpy+mkl package from http://www.lfd.uci.edu/~gohlke/pythonlibs/#scikit-learn and after successful installation restart the python

Lewis Parker
  • 71
  • 1
  • 6
2

Had the same problem. installing scipy solved the problem for me. Try...

#sudo pip install scipy

What does it say if you fire up a python prompt and type

import scipy

also there might be some pointers in this thread ImportError in importing from sklearn: cannot import name check_build

Community
  • 1
  • 1
Thom
  • 540
  • 5
  • 12