Celeb Glow
general | March 19, 2026

Cannot install scikit-learn in Python 3.4 in Ubuntu 14.04

I am trying to get scikit-learn to Python 3.4 in Ubuntu 14.04. When a run the command:

sudo pip3 install -U scikit-learn

I get scikit-learn loaded into Python 2.7. I have also tried to use:

sudo pip3 install git+

but I get only scikit-learn into Python 2.7. I am able load numpy and scipy into Python 3 using:

apt-get install python3-numpy python3-scipy

but python3-sklearn does not work.

I tried also to create a p3env but it did not work:

sudo virtualenv -p /usr/bin/python3 py3env
source py3env/bin/activate
(py3env)user:~$sudo pip install scikit-learn
Requiement already up-to-date:scikit-learn in /usr/local/lib/python2.7/dist-packages
5

3 Answers

I successfully installed scikit-learn for python3 on 14.04 using the following steps:

  • sudo apt-get install build-essential python3-dev python3-setuptools python3-numpy python3-scipy python3-pip libatlas-dev libatlas3gf-base
  • sudo pip3 install scikit-learn

According to the official doc, make sure that ATLAS is used to provide the implementation of the BLAS and LAPACK linear algebra routines:

sudo update-alternatives --set libblas.so.3 \ /usr/lib/atlas-base/atlas/libblas.so.3
sudo update-alternatives --set liblapack.so.3 \ /usr/lib/atlas-base/atlas/liblapack.so.3

I can now use scikit-learn:

$ python3
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from sklearn import datasets
>>> 
0

In general, many Python packages that do not have explicit python3 implementations in the package manager (aka, python-numpy, python3-numpy) are Python3 compatible and can be installed by downloading the package and running:

python3 setup.py install

In other words, the setup script from python3.

Many of the packages that are not immediately compatible require only a handful of common changes, for example print/print(), xrange()/range(), range()/list(range()), zip()/list(zip()).

You can probably also use the standard install process and then copy the libraries from the python2x "dist-packages" folders to the python3x "dist-packages" folders, but that is a bit sloppy.

I used the command

sudo apt-get install python3-sklearn python3-sklearn-lib python3-sklearn-doc

to install scikit-learn to use Python 3.6 on Ubuntu 18.04.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy