At this time scikit-learn does not provide official binary packages for Linux
so you have to build from source if you want the lastest version.
If you don’t need the newest version, consider using your package manager to
install scikit-learn. it is usually the easiest way, but might not provide the
newest version.

installing from source requires you to have installed the scikit-learn runtime
dependencies, python development headers and a working c/c++ compiler.
under debian-based operating systems, which include ubuntu, if you have
python 2 you can install all these requirements by issuing:

in order to build the documentation and run the example code contains in
this documentation you will need matplotlib:

sudo apt-get install python-matplotlib

Note

the above installs the atlas implementation of blas
(the basic linear algebra subprograms library).
ubuntu 11.10 and later, and recent (testing) versions of debian,
offer an alternative implementation called openblas.

using openblas can give speedups in some scikit-learn modules,
but can freeze joblib/multiprocessing prior to openblas version 0.2.8-4,
so using it is not recommended unless you know what you’re doing.

if you do want to use openblas, then replacing atlas only requires a couple
of commands. atlas has to be removed, otherwise numpy may not work:

this is usually the fastest way to install or upgrade to the latest stable
release:

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

the --user flag asks pip to install scikit-learn in the $home/.local
folder therefore not requiring root permission. this flag should make pip
ignore any old version of scikit-learn previously installed on the system while
benefiting from system packages for numpy and scipy. those dependencies can
be long and complex to build correctly from source.

the --install-option="--prefix=" flag is only required if python has a
distutils.cfg configuration with a predefined prefix= entry.

download the source package from
pypi,
, unpack the sources and cd into the source directory.

this packages uses distutils, which is the default way of installing
python modules. the install command is:

python setup.py install

or alternatively (also from within the scikit-learn source folder):

pip install .

Warning

packages installed with the pythonsetup.pyinstall command cannot
be uninstalled nor upgraded by pip later. to properly uninstall
scikit-learn in that case it is necessary to delete the sklearn folder
from your python site-packages directory.

to build scikit-learn on windows you need a working c/c++ compiler in
addition to numpy, scipy and setuptools.

picking the right compiler depends on the version of python (2 or 3)
and the architecture of the python interpreter, 32-bit or 64-bit.
you can check the python version by running the following in cmd or
powershell console:

python--version

and the architecture with:

python -c "import struct; print(struct.calcsize('p') * 8)"

the above commands assume that you have the python installation folder in your
path environment variable.

it is possible to use mingw (a port of gcc to windows
os) as an alternative to msvc for 32-bit python. not that extensions built with
mingw32 can be redistributed as reusable packages as they depend on gcc runtime
libraries typically not installed on end-users environment.

to force the use of a particular compiler, pass the --compiler flag to the
build step:

testing requires having the nose library. after
installation, the package can be tested by executing from outside the
source directory:

$ nosetests -v sklearn

under windows, it is recommended to use the following command (adjust the path
to the python.exe program) as using the nosetests.exe program can badly
interact with tests that use multiprocessing:

c:\python34\python.exe -c "import nose; nose.main()" -v sklearn

this should give you a lot of output (and some warnings) but
eventually should finish with a message similar to:

ran 3246 tests in 260.618s
ok (skip=20)

otherwise, please consider posting an issue into the bug tracker or to the
Mailing List including the traceback of the individual failures
and errors. please include your operation system, your version of numpy, scipy
and scikit-learn, and how you installed scikit-learn.