How to Install scikit-learn in Python

v1.8.0 Data & Science Python >=3.11

A set of python modules for machine learning and data mining

Install pip install scikit-learn

What is scikit-learn?

A set of python modules for machine learning and data mining

scikit-learn is a Python module for machine learning built on top of SciPy and is distributed under the 3-Clause BSD license.

The project was started in 2007 by David Cournapeau as a Google Summer of Code project, and since then many volunteers have contributed. See the page for a list of core contributors.

It is currently maintained by a team of volunteers.

Quick Start

Minimal example to get started with scikit-learn:

from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split

iris = load_iris()
X_train, X_test, y_train, y_test = train_test_split(
    iris.data, iris.target, test_size=0.2
)
clf = RandomForestClassifier()
clf.fit(X_train, y_train)
print(clf.score(X_test, y_test))  # ~0.97

Installation

pip (standard)

pip install scikit-learn

Virtual environment (recommended)

python -m venv venv
source venv/bin/activate   # Windows: venv\Scripts\activate
pip install scikit-learn

pip3

pip3 install scikit-learn

conda

conda install -c conda-forge scikit-learn

Poetry

poetry add scikit-learn

Dependencies

Installing scikit-learn will also install these packages:

Verify the Installation

After installing, confirm the package is available:

python -c "import sklearn; print(sklearn.__version__)"

If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.

Installation Errors

Common errors when installing scikit-learn with pip.

ModuleNotFoundError: No module named 'sklearn'

Cause: The package is not installed in the current Python environment.

Fix: Run pip install scikit-learn. If using a virtual environment, ensure it is activated first.

ModuleNotFoundError: No module named 'sklearn' (installed but still failing)

Cause: pip installed the package into a different Python than the one running your script.

Fix: Use python -m pip install scikit-learn to install into the interpreter you are running.

ImportError: cannot import name 'X' from 'sklearn'

Cause: The function or class does not exist in the installed version.

Fix: Check the version with pip show scikit-learn and upgrade with pip install --upgrade scikit-learn.

pip: command not found

Cause: pip is not in PATH or Python was not added to PATH during installation.

Fix: Try python -m pip install scikit-learn. On macOS/Linux try pip3.

PermissionError: [Errno 13] Permission denied

Cause: No write access to the system Python package directory.

Fix: Use a virtual environment, or add --user: pip install --user scikit-learn

SSL: CERTIFICATE_VERIFY_FAILED

Cause: pip cannot verify PyPI's SSL certificate — common behind corporate proxies.

Fix: Try: pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org scikit-learn

MemoryError when loading data

Cause: Dataset is too large to fit in RAM.

Fix: Read in chunks, filter columns on load, or consider Polars/Dask for out-of-core processing.

Recent Releases

VersionReleased
1.8.0 latest 2025-12-10
1.8.0rc1 2025-11-26
1.7.2 2025-09-09
1.7.1 2025-07-18
1.7.0 2025-06-05

Full release history on PyPI →

Manage scikit-learn

Upgrade to latest version

pip install --upgrade scikit-learn

Install a specific version

pip install scikit-learn==1.8.0

Uninstall

pip uninstall scikit-learn

Check what is installed

pip show scikit-learn

Last updated: 2026-04-11 • Data from PyPI