, , , ,

Introduction to and Installation of the Scikit-Learn Library

admin Avatar

Scikit-learn (formerly scikits.learn and also known as Sklearn) is a powerful library for machine learning in Python. It offers tools for classification, regression, clustering, and dimensionality reduction, using a consistent interface, and is based on NumPy, SciPy, and Matplotlib. This project is a community initiative; contributions are welcome on https://github.com/scikit-learn/scikit-learn/.

The latest release can be installed using pip or conda. In the former way (pip), Python 3 is often pre-installed on Linux. Check its installation by trying:

$ python3 --version
$ pip3 --version

Please install Python 3 and python3-pip using your distribution’s package manager. Create a virtual environment (venv) and install scikit-learn. The virtual environment is optional but recommended.

$ python3 -m venv sklearn-env
$ source sklearn-env/bin/activate  # activate
$ pip3 install -U scikit-learn

Check your installation using the following commands:

$ python3 -m pip show scikit-learn  # show scikit-learn version and location
$ python3 -m pip freeze             # show all installed packages in the environment
$ python3 -c "import sklearn; sklearn.show_versions()"

Output:

Name: scikit-learn
Version: 1.7.2

contourpy==1.3.2
cycler==0.12.1
fonttools==4.61.1
joblib==1.5.2
kiwisolver==1.4.9
matplotlib==3.10.8
numpy==2.2.6
packaging==25.0
pandas==2.3.3
pillow==12.0.0
pyparsing==3.2.5
python-dateutil==2.9.0.post0
pytz==2025.2
scikit-learn==1.7.2
scipy==1.15.3
seaborn==0.13.2
six==1.17.0
threadpoolctl==3.6.0
tzdata==2025.3

System:
    python: 3.10.12 [GCC 11.4.0]
Python dependencies:
      sklearn: 1.7.2
          pip: 22.0.2
   setuptools: 59.6.0
        numpy: 2.2.6
        scipy: 1.15.3
       Cython: None
       pandas: 2.3.3
   matplotlib: 3.10.8
       joblib: 1.5.2
threadpoolctl: 3.6.0

The virtual environment can be deactivated using the following command:

$ deactivate

In the latter way (conda), please install conda with conda-forge installers, no admin needed. Then run:

$ conda create -n sklearn-env -c conda-forge scikit-learn
$ conda activate sklearn-env

Check your installation using the following commands:

$ conda list scikit-learn  # show scikit-learn version and location
$ conda list               # show all installed packages in the environment
$ python -c "import sklearn; sklearn.show_versions()"

Isolated environments like pip venv or conda allow independent installation of specific scikit-learn versions and dependencies, avoiding conflicts with the packages managed by the package manager of the distribution (apt, dnf, pacman, …), especially discouraged on Linux systems. Note that always activate your chosen environment before executing any Python commands in a new terminal session.

To install NumPy or SciPy, use conda or pip. When using pip, ensure binary wheels are used to avoid recompiling from source, which may occur with specific OS and hardware configurations, like Linux on Raspberry Pi. Scikit-learn plotting functions need Matplotlib, with some examples also requiring scikit-image, pandas, or seaborn.

References
  1. scikit-learn: Machine Learning in Python. Installing scikit-learn. Retrieved November 15, 2025, from https://www.scikit-learn.org/.
  2. Tutorials Point. Scikit Learn Tutorial. Retrieved November 20, 2025, from https://www.tutorialspoint.com/.

Tagged in :

admin Avatar

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Love