Ubuntu – ImportError: No module named sklearn

14.04python-2.7scikit learn

I installed scikit-learn on following these instructions

Even when I try now to run again: sudo pip install -U scikit-learn

I get this message proving again that installation is ok:

Requirement already up-to-date: scikit-learn in /home/begueradj/.local/lib/python2.7/site-packages

But I fail to import it:

begueradj@begueradj-Sampo:~/Desktop/begueradj$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:38) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sklearn
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named sklearn

How to resolve this ?

Best Answer

The Ubuntu 14.04 package is named python-sklearn (formerly python-scikits-learn) and can be installed in Ubuntu 14.04-19.04 using the following command:

sudo apt install python-sklearn  

The python-sklearn package is in the default repositories in Ubuntu 14.04 as well as in other currently supported Ubuntu releases.

In Ubuntu 16.04 and later the Python 3 version of python-sklearn can be installed from the default Ubuntu repositories with the following command:

sudo apt install python3-sklearn