Skip to content

Latest commit

 

History

History
257 lines (186 loc) · 11.8 KB

install.rst

File metadata and controls

257 lines (186 loc) · 11.8 KB

Installing scikit-learn

There are different ways to install scikit-learn:

Installing the latest release

Operating System Windows macOS Linux
Packager pip conda
Install the 64bit version of Python 3, for instance from https://www.python.org.Install Python 3 using homebrew (brew install python) or by manually installing the package from https://www.python.org.Install python3 and python3-pip using the package manager of the Linux Distribution.Install conda (no administrator permission required).

Then run:

python3 -m venv sklearn-venvpython -m venv sklearn-venvpython -m venv sklearn-venvsource sklearn-venv/bin/activatesource sklearn-venv/bin/activatesklearn-venv\Scripts\activatepip install -U scikit-learnpip install -U scikit-learnpip install -U scikit-learnpip3 install -U scikit-learnconda create -n sklearn-envconda activate sklearn-envconda install scikit-learn 

In order to check your installation you can use

python3 -m pip show scikit-learn  # to see which version and where scikit-learn is installedpython3 -m pip freeze  # to see all packages installed in the active virtualenvpython3 -c "import sklearn; sklearn.show_versions()"python -m pip show scikit-learn  # to see which version and where scikit-learn is installedpython -m pip freeze  # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions()"python -m pip show scikit-learn  # to see which version and where scikit-learn is installedpython -m pip freeze  # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions()"python -m pip show scikit-learn  # to see which version and where scikit-learn is installedpython -m pip freeze  # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions()"conda list scikit-learn  # to see which scikit-learn version is installedconda list  # to see all packages installed in the active conda environmentpython -c "import sklearn; sklearn.show_versions()"

Note that in order to avoid potential conflicts with other packages it is strongly recommended to use a virtual environment, e.g. python3 virtualenv (see python3 virtualenv documentation) or conda environments.

Using an isolated environment makes possible to install a specific version of scikit-learn and its dependencies independently of any previously installed Python packages. In particular under Linux is it discouraged to install pip packages alongside the packages managed by the package manager of the distribution (apt, dnf, pacman...).

Note that you should always remember to activate the environment of your choice prior to running any Python command whenever you start a new terminal session.

If you have not installed NumPy or SciPy yet, you can also install these using conda or pip. When using pip, please ensure that binary wheels are used, and NumPy and SciPy are not recompiled from source, which can happen when using particular configurations of operating system and hardware (such as Linux on a Raspberry Pi).

If you must install scikit-learn and its dependencies with pip, you can install it as scikit-learn[alldeps].

Scikit-learn plotting capabilities (i.e., functions start with "plot_" and classes end with "Display") require Matplotlib (>= 1.5.1). For running the examples Matplotlib >= 1.5.1 is required. A few examples require scikit-image >= 0.12.3, a few examples require pandas >= 0.18.0.

Warning

Scikit-learn 0.20 was the last version to support Python 2.7 and Python 3.4. Scikit-learn now requires Python 3.5 or newer.

Note

For installing on PyPy, PyPy3-v5.10+, Numpy 1.14.0+, and scipy 1.1.0+ are required.

Third party distributions of scikit-learn

Some third-party distributions provide versions of scikit-learn integrated with their package-management systems.

These can make installation and upgrading much easier for users since the integration includes the ability to automatically install dependencies (numpy, scipy) that scikit-learn requires.

The following is an incomplete list of OS and python distributions that provide their own version of scikit-learn.

Arch Linux

Arch Linux's package is provided through the official repositories as python-scikit-learn for Python. It can be installed by typing the following command:

$ sudo pacman -S python-scikit-learn

Debian/Ubuntu

The Debian/Ubuntu package is splitted in three different packages called python3-sklearn (python modules), python3-sklearn-lib (low-level implementations and bindings), python3-sklearn-doc (documentation). Only the Python 3 version is available in the Debian Buster (the more recent Debian distribution). Packages can be installed using apt-get:

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

Fedora

The Fedora package is called python3-scikit-learn for the python 3 version, the only one available in Fedora30. It can be installed using dnf:

$ sudo dnf install python3-scikit-learn

NetBSD

scikit-learn is available via pkgsrc-wip:

http://pkgsrc.se/math/py-scikit-learn

MacPorts for Mac OSX

The MacPorts package is named py<XY>-scikits-learn, where XY denotes the Python version. It can be installed by typing the following command:

$ sudo port install py36-scikit-learn

Canopy and Anaconda for all supported platforms

Canopy and Anaconda both ship a recent version of scikit-learn, in addition to a large set of scientific python library for Windows, Mac OSX and Linux.

Anaconda offers scikit-learn as part of its free distribution.

Intel conda channel

Intel maintains a dedicated conda channel that ships scikit-learn:

$ conda install -c intel scikit-learn

This version of scikit-learn comes with alternative solvers for some common estimators. Those solvers come from the DAAL C++ library and are optimized for multi-core Intel CPUs.

Note that those solvers are not enabled by default, please refer to the daal4py documentation for more details.

Compatibility with the standard scikit-learn solvers is checked by running the full scikit-learn test suite via automated continuous integration as reported on https://github.com/IntelPython/daal4py.

WinPython for Windows

The WinPython project distributes scikit-learn as an additional plugin.