Open In App

How to Install Packages in Python on Linux?

Improve
Improve
Like Article
Like
Save
Share
Report

To install a package in python, we use pip. The pip is a python package manager. In this tutorial, we will be discussing how we can install packages in python on a Linux system.

To install packages in python on Linux, we must have python and pip installed on our Linux machine. As python comes preinstalled with the Linux system, we may have to install pip manually if we are using python 2.9 or below.

Installing PIP on Linux:

To install pip, follow the following methods:

Method 1: Using apt install command

sudo apt install pip

Method 2: Using python script to install pip

Step 1: Go through the following website and download the script.

https://bootstrap.pypa.io/get-pip.py

Or using the following command, you can download the python script to install pip:

wget https://bootstrap.pypa.io/get-pip.py

downloading python script

    Step 2: Run the script using python

python3 get-pip.py

Output:

installing pip on linux

installing pip

After installing pip, do the following steps to install a python package:

Step 1: Go through the following website and search for the package that you want to install and hit enter.

https://pypi.org/

For example, we are going to search for pandas. A popular library to manipulate CSV files.

installing pandas

Step 2: Click on the package that you want to install and copy the installation instruction.

installing pandas

Step 3: Now open up the terminal and paste the above-copied command and hit enter.

successfully installed pandas package on linux using pip

successfully installed pandas package

This will install the pandas package in python on your Linux machine.

To uninstall a package simply use the following command:

pip uninstall pandas

Here, pandas can be replaced with any other package name.


Last Updated : 23 Sep, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads