Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How to Install Scikit-Learn on Linux?

  • Last Updated : 17 Oct, 2021

In this article, we are going to see how to install Scikit-Learn on Linux. Scikit-Learn is a python open source library for predictive data analysis. It is built on NumPy, SciPy, and matplotlib. It is written in Python, Cython, C, and C++ language. It is available for Linux, Unix, Windows, and Mac.

Method 1: Installing Scikit-Learn from source

Step 1: Installing python3 and the essentials dependencies to build the Scikit-learn.

sudo apt-get install build-essential python3-dev python3-pip

How to Install Scikit-Learn on Linux?

installing python

Step 2: Got the scikit-learn repository and clone it using the following command.

git clone git://github.com/scikit-learn/scikit-learn.git --depth 1
cd scikit-learn
How to Install Scikit-Learn on Linux?

Downloading Scikit-Learn

Step 3: Create a virtual environment for separate installation of Scikit-learn.

To install the python3-virtualenv tool, if you have not installed it yet.

sudo apt install python3.8-venv

Run the following command to create and activate the virtual environment.

python3 -m venv geeks-env

This will create a virtual environment called geeks-env

source geeks-env/bin/activate
How to Install Scikit-Learn on Linux?

Activating virtual environment

The above command will activate the virtual environment.

Step 4: Now, Install NumPy, SciPy, and Cython and build the package with pip in Editable mode:

pip install numpy scipy cython
How to Install Scikit-Learn on Linux?

installing  NumPy, SciPy, and Cython

Building the package:

pip install --verbose --no-build-isolation --editable .
How to Install Scikit-Learn on Linux?

building from source

Step 5: Verifying the installation.

python3 -c "import sklearn; sklearn.show_versions()"
How to Install Scikit-Learn on Linux?

Verifying the installation

Method 2: Installing Scikit-Learn using the pip command

Step 1: Install Scikit-learn using the following pip installation command:

pip3 install -U scikit-learn
How to Install Scikit-Learn on Linux?

installing scikit learn

Step 2: Verify the installation by running the following command:

python3 -m pip show scikit-learn

successfully installed scikit-learn

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!