ImportError: No module named sklearn
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
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!