Install the latest official release. This
is the best approach for most users. It will provide a stable version
and pre-built packages are available for most platforms.
Install the version of scikit-learn provided by your
operating system or Python distribution.
This is a quick option for those who have operating systems or Python
distributions that distribute scikit-learn.
It might not provide the latest release version.
Install a nightly build. This is the quickest way to
try a new feature that will be shipped in the next release (that is, a
feature from a pull-request that was recently merged to the main branch); or to check
whether a bug you encountered has been fixed since the last release.
Building the package from source.
This is mainly needed by users who wish to contribute to the project, as this allows
to install an editable version of the project.
Installing the latest release
Windows
pip
Install the 64-bit version of Python 3, for instance from the
official website.
Now create a virtual environment (venv) and install scikit-learn.
Note that the virtual environment is optional but strongly recommended, in
order to avoid potential conflicts with other packages.
python-mpipshowscikit-learn# show scikit-learn version and locationpython-mpipfreeze# show all installed packages in the environmentpython-c"import sklearn; sklearn.show_versions()"
conda
Install conda using the
conda-forge installers (no
administrator permission required). Then run:
condalistscikit-learn# show scikit-learn version and locationcondalist# show all installed packages in the environmentpython-c"import sklearn; sklearn.show_versions()"
MacOS
pip
Install Python 3 using homebrew (brewinstallpython)
or by manually installing the package from the official website.
Now create a virtual environment (venv) and install scikit-learn.
Note that the virtual environment is optional but strongly recommended, in
order to avoid potential conflicts with other packages.
python-mpipshowscikit-learn# show scikit-learn version and locationpython-mpipfreeze# show all installed packages in the environmentpython-c"import sklearn; sklearn.show_versions()"
conda
Install conda using the
conda-forge installers (no
administrator permission required). Then run:
condalistscikit-learn# show scikit-learn version and locationcondalist# show all installed packages in the environmentpython-c"import sklearn; sklearn.show_versions()"
Linux
pip
Python 3 is usually installed by default on most Linux distributions. To
check if you have it installed, try:
python3 --version
pip3 --version
If you don’t have Python 3 installed, please install python3 and
python3-pip from your distribution’s package manager.
Now create a virtual environment (venv) and install scikit-learn.
Note that the virtual environment is optional but strongly recommended, in
order to avoid potential conflicts with other packages.
python3-mpipshowscikit-learn# show scikit-learn version and locationpython3-mpipfreeze# show all installed packages in the environmentpython3-c"import sklearn; sklearn.show_versions()"
conda
Install conda using the
conda-forge installers (no
administrator permission required). Then run:
condalistscikit-learn# show scikit-learn version and locationcondalist# show all installed packages in the environmentpython-c"import sklearn; sklearn.show_versions()"
Using an isolated environment such as pip venv or conda makes it possible to
install a specific version of scikit-learn with pip or conda and its dependencies
independently of any previously installed Python packages. In particular under Linux
it is 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).
Scikit-learn plotting capabilities (i.e., functions starting with plot_
and classes ending with Display) require Matplotlib. The examples require
Matplotlib and some examples require scikit-image, pandas, or seaborn. The
minimum version of scikit-learn dependencies are listed below along with its
purpose.
Dependency
Minimum Version
Purpose
numpy
1.24.1
build, install
scipy
1.10.0
build, install
joblib
1.4.0
install
narwhals
2.0.1
install
threadpoolctl
3.5.0
install
cython
3.1.2
build
meson-python
0.17.1
build
matplotlib
3.6.1
benchmark, docs, examples, tests
scikit-image
0.22.0
docs, examples
pandas
1.5.0
benchmark, docs, examples, tests
rich
14.1.0
docs, examples, tests
seaborn
0.13.0
docs, examples
memory_profiler
0.57.0
benchmark, docs
pytest
7.1.2
tests
pytest-cov
2.9.0
tests
ruff
0.12.2
tests
pyrefly
1.2.0
tests
cython-lint
0.21
tests
sphinx-lint
1.0.2
tests
codespell
2.4.1
tests
pyamg
5.0.0
tests
polars
0.20.30
docs, tests
pyarrow
13.0.0
tests
sphinx
7.3.7
docs
sphinx-copybutton
0.5.2
docs
sphinx-gallery
0.17.1
docs
numpydoc
1.2.0
docs, tests
Pillow
12.1.1
docs
pooch
1.8.0
docs, examples, tests
sphinx-prompt
1.4.0
docs
sphinxext-opengraph
0.9.1
docs
plotly
5.22.0
docs, examples
sphinx-remove-toctrees
1.0.0.post1
docs
sphinx-design
0.6.0
docs
pydata-sphinx-theme
0.15.3
docs
towncrier
24.8.0
docs
conda-lock
3.0.1
maintenance
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.
Alpine Linux
Alpine Linux’s package is provided through the official repositories as
py3-scikit-learn for Python.
It can be installed by typing the following command:
sudo apk add py3-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 split in three different packages called
python3-sklearn (python modules), python3-sklearn-lib (low-level
implementations and bindings), python-sklearn-doc (documentation).
Note that scikit-learn requires Python 3, hence the need to use the python3-
suffixed package names.
Packages can be installed using apt-get:
The MacPorts package is named py<XY>-scikit-learn,
where XY denotes the Python version.
It can be installed by typing the following
command:
sudo port install py312-scikit-learn
Anaconda and Enthought Deployment Manager for all supported platforms
Anaconda and
Enthought Deployment Manager
both ship with 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 Extension for Scikit-learn
Intel maintains an optimized x86_64 package, available in PyPI (via pip),
and in the main, conda-forge and intel conda channels:
conda install scikit-learn-intelex
This package has an Intel optimized version of many estimators. Whenever
an alternative implementation doesn’t exist, scikit-learn implementation
is used as a fallback. Those optimized solvers come from the oneDAL
C++ library and are optimized for the x86_64 architecture, and are
optimized for multi-core Intel CPUs.
Note that those solvers are not enabled by default, please refer to the
scikit-learn-intelex
documentation for more details on usage scenarios. Direct export example:
from
WinPython for Windows
The WinPython project distributes
scikit-learn as an additional plugin.
Troubleshooting
If you encounter unexpected failures when installing scikit-learn, you may submit
an issue to the issue tracker.
Before that, please also make sure to check the following common issues.
Error caused by file path length limit on Windows
It can happen that pip fails to install packages when reaching the default path
size limit of Windows if Python is installed in a nested location such as the
AppData folder structure under the user home directory, for instance:
In this case it is possible to lift that limit in the Windows registry by
using the regedit tool:
Type “regedit” in the Windows start menu to launch regedit.
Go to the
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
key.
Edit the value of the LongPathsEnabled property of that key and set
it to 1.
Reinstall scikit-learn (ignoring the previous broken installation):
pipinstall--exists-action=iscikit-learn
Installing nightly builds
The continuous integration servers of the scikit-learn project build, test
and upload wheel packages for the most recent Python version on a nightly
basis.
You can install the nightly build of scikit-learn using the scientific-python-nightly-wheels
index from the PyPI registry of anaconda.org:
Note that first uninstalling scikit-learn might be required to be able to
install nightly builds of scikit-learn.
sklearnex.neighbors
import
NearestNeighbors
Compatibility with the standard scikit-learn solvers is checked by running the
full scikit-learn test suite via automated continuous integration as reported
on intel/scikit-learn-intelex. If you observe any issue
with scikit-learn-intelex, please report the issue on their
issue tracker.