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 ?

3 Answers 3


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 
  • python-sklearn is in the default Ubuntu repositories for all currently supported versions of Ubuntu at least up to Ubuntu 15.10.
    – karel
    Aug 28, 2015 at 2:14
  • And what about 16.04 ? Jul 24, 2017 at 10:29
  • python-sklearn is available from the default Ubuntu repositories in all currently supported Ubuntu releases up to 19.04. In 19.10 and later .only the python3-sklearn package is in the default Ubuntu repositories.
    – karel
    Nov 18, 2019 at 10:52

When installing on Ubuntu Linux you have to have to install dependencies first using apt-get, then use a pip install otherwise the normal pip install of scikit-learn won't work properly. See below:

Step 1: Make sure apt-get is updated

sudo apt-get update

Step 2: Install dependencies

sudo apt-get install build-essential python-dev python-setuptools python-numpy python-scipy libatlas-dev libatlas3gf-base

Step 3: pip install Scikit Learn

pip install --user --install-option="--prefix=" -U scikit-learn

Hope this helps!


I've tried a lot of things but finally, including uninstall with the automated tools. So, I've uninstalled manually scikit-learn.

sudo rm -R /home/ubuntu/.local/lib/python3.6/site-packages/sklearn
sudo rm -R /home/ubuntu/.local/lib/python3.6/site-packages/scikit_learn-0.20.0-py3.6.egg-info

And re-install using pip

sudo pip3.6 install -U scikit-learn

You must log in to answer this question.