Cyber Month Deal - up to 36% OFF

How to Install PIP on Ubuntu 22.04 | Step-by-Step

Published on May 25, 2023 Updated on Nov 1, 2024

In this step-by-step guide, we will walk you through how to install pip on Ubuntu 22.04. In addition, you will also learn how to install and uninstall Python packages using pip, as well as how to upgrade it to the latest version.

What is PIP?

PIP, a recursive acronym for Pip Install Packages, is the standard package manager for Python. It uses the Python Package Index (PyPI) as the default software repository for installing Python packages.

PIP automates the installation of Python packages while handling dependencies. This eliminates the need for manual installation and ensures all dependencies required by the package are met. In addition, you can perform other operations such as listing, upgrading, and removing packages.

Deploy and scale your Python projects effortlessly on Cherry Servers' robust and cost-effective dedicated or virtual servers. Benefit from an open cloud ecosystem with seamless API & integrations and a Python library.

Prerequisites

Before you roll your sleeves, ensure that you have the following requirements in place

Step 1: Confirm if Python is Installed

The first step is to ensure that Python is installed on your system. Thankfully, Ubuntu 22.04 provides Python 3.10 out of the box. You can confirm this by running the following command:

python3 -V

OR

python3  --version

The output below confirms that we have Python already installed.

python3 --version

If Python is missing from your system, install it using the following commands.

sudo apt update
 sudo apt install python3 -y

Step 2: Install PIP on Ubuntu 22.04

By default, pip is not installed. In fact, you run into an error when you try to install a Python package as shown here below.

pip3  install numpy

pip3 install numpy

To install the latest version of pip, run the following command:

sudo apt install python3-pip -y

This installs pip3 alongside other additional packages, libraries, and dependencies.

Install pip3

Step 3: Verify the Installation of PIP

Once the installation is complete, verify that PIP is installed using the following command.

pip3  -V

OR

pip3  --version

pip3 --version

Additionally, you can verify the path of the executable file associated with the pip utility.

which pip3

which pip3

To get started with pip, you can list all the available options that are available using the package manager as shown.

 pip3  --help

The output displays all the command-line options that can be used using pip.

pip3 --help

You can narrow it down to a specific command option. For example, run the following command to display options associated with pip3 install.

 pip3  install --help

pip3 install --help

Discover how Caxita, an online travel engine application company with high workloads, eliminated downtime and allowed engineers to focus on development thanks to Cherry Servers' robust bare metal cloud and 24/7 technical support.

How to Install and Manage Packages Using PIP

So far, we have successfully managed to install pip. To add the icing to the cake, we will go a step further and demonstrate how to use the pip package manager to install and manage installed packages.

To install a package, use the following syntax:

pip3  install package_name

For example, to install pandas, an open source Python library widely used in Data Science and Machine Learning, run the command:

pip3 install pandas

Additionally, you can install multiple packages in a single command. The following command installs pandas and matplotlib Python libraries.

pip3  install matplotlib pandas

pip3 install matplotlib pandas

To list installed Python packages, run the command:

pip3  list

The command lists all the installed Python packages. However, if you want to check if a specific package is installed, pipe the output to the grep command.

Here, we are checking for the existence of pandas and matplotlib Python packages on our system.

pip3  list | grep -i pandas
pip3  list | grep -i matplotlib

pip3 list | grep -i matplotlib

To display information about a specific package, use the syntax:

pip3  show package_name

For example, to probe for information about the pandas package, run:

pip3  show pandas

The output provides information such as the name, version, author, and a brief summary of the package among other details.

pip3 show pandas

To upgrade a Python package to its latest version, invoke the --upgrade or -U option.

pip3 install --upgrade package-name
pip3 install -U package-name

For example, to update the matplotlib package, run the command:

pip3 install --upgrade matplotlib

If the package is already in its latest version, no change will be affected.

pip3 install --upgrade matplotlib

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

pip3 install --upgrade pip

pip3 install --upgrade pip

To remove or uninstall a package, use the syntax.

pip3 uninstall package-name

For example, to remove Pandas, run the command:

pip3 uninstall pandas

pip3 uninstall pandas

Conclusion

In this tutorial, we have demonstrated how to install pip on Ubuntu 22.04. In addition, we have gone the extra mile to show you how to use pip to install and manage already installed Python packages.

Cloud VPS - Cheaper Each Month

Start with $9.99 and pay $0.5 less until your price reaches $6 / month.

Share this article

Related Articles

Published on Aug 21, 2019 Updated on Jun 15, 2023

Can DDoS attacks harm your server and how to prevent them?

DDoS attacks can cause real harm to your system. Learn some practical examples of how to lower the risk and how to prevent ddos attacks.

Read More
Published on Nov 28, 2019 Updated on Aug 8, 2023

Streaming Servers: Everything You Need To Know

What are Live Streaming servers. How do they work? Why do you need a stable and fast network? We will try to cover these topics on our article.

Read More
Published on Jul 8, 2022 Updated on Oct 4, 2023

How to Install and Configure Apache Reverse Proxy Server With SSL/TLS Encryption

This step-by-step guide will explain what a reverse proxy is and show you how to install Apache reverse proxy server with SSL/TLS encryption.

Read More
We use cookies to ensure seamless user experience for our website. Required cookies - technical, functional and analytical - are set automatically. Please accept the use of targeted cookies to ensure the best marketing experience for your user journey. You may revoke your consent at any time through our Cookie Policy.
build: 06ac5732e.831