'sklearn ImportError: No module named _check_build
I'm trying to import sklearn, however when I attempt to do so I receive the following:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-8fd979e02004> in <module>()
----> 1 import sklearn
C:\Users\Alpine\AppData\Local\Enthought\Canopy\User\sklearn\__init__.py in <module>()
29 # process, as it may not be compiled yet
30 else:
---> 31 from . import __check_build
32 from .base import clone
33
C:\Users\Alpine\AppData\Local\Enthought\Canopy\User\sklearn\__check_build\__init__.py in <module>()
44 from ._check_build import check_build
45 except ImportError as e:
---> 46 raise_build_error(e)
C:\Users\Alpine\AppData\Local\Enthought\Canopy\User\sklearn\__check_build\__init__.py in raise_build_error(e)
39 to build the package before using it: run `python setup.py install` or
40 `make` in the source directory.
---> 41 %s""" % (e, local_dir, ''.join(dir_content).strip(), msg))
42
43 try:
ImportError: No module named _check_build
___________________________________________________________________________
Contents of C:\Users\Alpine\AppData\Local\Enthought\Canopy\User\sklearn\__check_build:
setup.py setup.pyc _check_build.c
_check_build.pyx __init__.py __init__.pyc
___________________________________________________________________________
It seems that scikit-learn has not been built correctly.
If you have installed scikit-learn from source, please do not forget
to build the package before using it: run `python setup.py install` or
`make` in the source directory.
If you have used an installer, please check that it is suited for your
Python version, your operating system and your platform.
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line string', (1, 2))
I'm fairly sure that scikit-learn has been correctly built as I managed to run python setup.py install
without any incident. I did however try running python setup.py bdist_wininst -b doc/logos/scikit-learn-logo.bmp
though was interrupted at error: cannot copy tree 'build\scripts.win-amd64-2.7': not a directory
.
Might anybody have an idea on how to fix this?
Solution 1:[1]
I have the same problem on Windows 10. I installed Anaconda with Python 3.7 and this installation shipped not only this problem. To solve run in anaconda prompt:
conda install scikit-learn
At least this worked for me
Solution 2:[2]
OK, the following is work for me :)
sudo make
sudo python setup.py install
Finally, to test whether installation is ok:
nosetests --exe sklearn
Solution 3:[3]
One way to avoid this error is to make sure you have all the needed dependencies installed. Under Ubuntu / Debian, you can accomplish this by running the following:
sudo apt-get build-dep python-sklearn
Solution 4:[4]
This doesn't exactly fit your question as it doesn't involve Enthought distribution; however, I had a similar problem with a module using sklearn
. The error was something like:
$ python -m somefile.py // somefile.py uses sklearn at some point
Cannot import name __check_build
And after I installed scikit-learn
(also,scipy
and numpy-MKL
) from this page the problem seemed to go away.
Solution 5:[5]
Make sure you are executing the code with the latest python version. If you have multiple python version installed in your machine then just remove the first line "#!/usr/bin/python" and try running with full path of latest python version like "/usr/local/bin/python3.4 'filename'". If you have python version lower than 2.7 then try upgrading the version and installing the dependencies and then try the above method.
Solution 6:[6]
In my case I had Python installed at two places, first by myself where I independently installed python and it was in a separate folder, second time by anaconda which installs python within its own folder. So every-time I called Scikit Learn it was refereeing to the first python folder which had some issues with scikit learn but when I removed old Python folder completely jupyter notebook was refereeing to the correct python folder and hence it worked.
Solution 7:[7]
I am using Anaconda and this worked for me:
conda install scikit-learn
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Okroshiashvili |
Solution 2 | RyanLiu |
Solution 3 | Mark |
Solution 4 | icedwater |
Solution 5 | Krupesh Patel |
Solution 6 | anushreep2018 |
Solution 7 | Josue |