How to Install Pip on Ubuntu? (Step by Step Guide: Install Pip on Ubuntu)

Published on September 09, 2024, Updated on December 17, 2024


PIP stands for "Pip Installs Packages", a standard tool for managing Python packages. It relies on the Python Package Index (PyPI) as its primary source for downloading and installing Python packages.

PIP streamlines the process of installing Python packages and automatically manages their dependencies. This means you don't have to manually install each dependency, as PIP includes all necessary packages. Additionally, PIP allows you to perform other tasks such as listing installed packages, upgrading them, and removing them when no longer needed.

This step-by-step guide will show you how to install pip on Ubuntu 22.04. You will also learn how to use pip to install and uninstall Python packages, and how to upgrade pip to the latest version.

Prerequisites

Before getting started, make sure you have the following:

  • A running instance of the Ubuntu 22.04 server.
  • You should have SSH access to the server with a configured sudo user. 

Steps to Install Pip on Ubuntu 22.04

To install the Pip python package manager on the Ubuntu 22.04 system, you need to perform the following steps:

Step 1: Check the Python Installation

First, verify that Python is installed on your system. Python 3.10.12 comes pre-installed with Ubuntu 22.04. However, you can also check the Python installation by running the below command:

$ python3 -V

or

$ python3 --version

You should see an output like this, indicating Python is already installed:

If Python is not installed, first, you will need to install Python by running the following commands:

$ sudo apt update

The above command will update the Ubuntu apt repositories. After that, you can install Python using this command:

$ sudo apt install python3 -y

Step 2: Installing Pip on Ubuntu 22.04

By default, pip is not installed on Ubuntu. If you try to install a Python package without pip, you will encounter an error. So, start installing pip on Ubuntu 22.04. You can install the latest version of pip by executing this command:

$ sudo apt install python3-pip -y

This will install pip3 along with all required packages, libraries, and dependencies.

Step 3: Verify Pip Installation 

Once the installation is complete, confirm that PIP is installed by running:

$ pip3 -V

or

pip3 --version

To check the path of the pip executable file, use:

$ which pip3

To explore the available options with pip, you can display all command-line options by running:

$ pip3 --help

This will show all the commands you can use with pip. 

How to Manage and Install Python Packages Using PIP?

Once you successfully install pip on your Ubuntu system, you can install and manage Python packages using pip. Now, let's explore how to use it to manage Python packages.

Installing Python Packages Using Pip:

To install a package, use this syntax:

$ pip3 install package_name

For instance, to install the numpy library, which is popular in calculations and a fundamental package in array computing, run the below command:

$ pip3 install numpy

You can also install multiple packages simultaneously. For example, to install pandas and numpy, use:

$ pip3 install pandas numpy

List Installed Packages Using Pip:

To view all installed Python packages, use:

$ pip3 list

Check Packages Installation Using Pip with grep Command:

If you want to check if a specific package is installed, combine it with the grep command. For example, to check for pandas and numpy, run:

$ pip3 list | grep -i pandas

$ pip3 list | grep -i numpy

Display Details of a Package with Pip:

To get details about a specific package, use:

$ pip3 show package_name

For example, to see information about numpy, run:

$ pip3 show numpy

Update Packages Using Pip:

To update a package to its latest version, use the --upgrade or -U option:

$ pip3 install --upgrade package_name

$ pip3 install -U package_name

For example, to update numpy, use:

$ pip3 install --upgrade numpy

Upgrade Pip: 

To upgrade the pip itself to the latest version, run:

$ pip3 install --upgrade pip

Uninstall Packages Using Pip:

To uninstall a package, use the following syntax:

$ pip3 uninstall package_name

For example, to remove the numpy package from your system, run the below command:

$ pip3 uninstall numpy

Conclusion

In this guide, we demonstrated how to install pip on Ubuntu 22.04. In addition, we have also learned how to use pip to install, manage, and uninstall Python packages on the Ubuntu system. I hope the above step-by-step Pip installation instructions will help you install Pip on your Ubuntu machine. 

Are you searching for a robust hosting solution for your VPS or dedicated server? Or perhaps you require SSL services?

Host World offers the ideal solutions for all your needs. Take a moment to review our advantages, and you'll see why we're the best choice available.