
How to Install and Use Pip on Ubuntu 22.04
Pip is a Python package manager that you use to install, upgrade, configure, and manage project dependencies. It also lets you search, download, and install packages from the Python Package Index (PyPI) and other package repositories.
This guide explains how to install pip for Python 3 and Python 2 on Ubuntu 22.04. Additionally, we will cover the basics of using pip to manage Python packages.
Before You Begin
In fact, Python exists in two versions: Python 2 and Python 3.
- Ubuntu 22.04 includes Python 3 by default.
- The Python core team no longer actively maintains Python 2, although you can still install it manually.
- We recommend using Python 3 for all new projects.
When installing Python modules globally, it is best to install them using Ubuntu’s apt package manager whenever possible, since Ubuntu tests these packages for compatibility.
Python packages follow this naming convention:
- The python3- prefix marks Python 3 packages
- Similarly, the python2- prefix marks Python 2 packages
Additionally, for project-specific installations, using a virtual environment is the preferred approach, as it prevents conflicts between dependencies.
Installing pip for Python 3
Installing pip for Python 3 on Ubuntu 22.04 is a simple process.
To begin with, update the package index and install pip using the following command:
sudo apt update
sudo apt install python3-pip
This command also installs any dependencies required for building Python modules.
Once you complete the installation, verify pip by checking its version:
pip3 –version
The output should look something like this:
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)
Installing pip for Python 2
The Ubuntu 22.04 repositories do not include pip for Python 2, so you need to install it manually using the get-pip.py script.
Step 1: Install Python 2
If you have not already installed Python 2, install it by running:
sudo apt update
sudo apt install python2
Step 2: Download the get-pip.py Script
After that, use the curl command to download the script from the official Python repository:
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py –output get-pip.py
Step 3: Install pip for Python 2
Then, run the script using Python 2:
sudo python2 get-pip.py
This command installs pip globally. However, if you only need pip for your user account, run it without sudo.
The script also installs setuptools and wheel, which allow you to install source distributions of Python packages.
Step 4: Verify the Installation
To confirm the installation succeeded, check the version number:
pip2 –version
The output should look something like this:
pip 20.3.4 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
How to Use Pip
Pip provides several useful commands for managing Python packages. In particular, the following are some of the most common ones.
To see a list of all pip commands and options, run:
pip3 –help
To get more information about a specific command, use the following syntax:
pip3 command –help
For example, to get more information about the install command, type:
pip3 install –help
Installing Packages with Pip
Specifically, the most basic function of pip is to install a package.
To install the latest version of a package, use the following command:
pip3 install package_name
For example, to install the NumPy library:
pip3 install numpy
Installing Packages with Pip Using Requirements Files
In short, a requirements.txt file is a text file containing a list of pip packages with their versions required to run a specific Python project.
To install a list of requirements specified in a file, use the following command:
pip3 install -r requirements.txt
As a result, this ensures pip installs every dependency at the specified version.
Listing Installed Packages
Then, to list all the installed pip packages, use the list subcommand:
pip3 list
Upgrading a Package with Pip
To upgrade an already installed package to the latest version, use the following command:
pip3 install –upgrade package_name
For example, to upgrade NumPy:
pip3 install –upgrade numpy
Uninstalling Packages with Pip
To remove an installed package, run the following command:
pip3 uninstall package_name
For example, to uninstall NumPy:
pip3 uninstall numpy
Using Pip with a Virtual Environment
For better package management, we recommend using pip inside a Python virtual environment. Virtual environments let you install packages in an isolated location for each project, which prevents dependency conflicts.
Installing the virtual environment package
Install the virtual environment package for Python 3:
sudo apt install python3-venv
Creating a Virtual Environment
Then, create a new virtual environment in a directory called myproject:
python3 -m venv myproject
Activating the Virtual Environment
Then, activate the virtual environment by running:
source myproject/bin/activate
Once activated, pip will install packages inside the virtual environment instead of system-wide.
Deactivating the Virtual Environment
Finally, to exit the virtual environment, simply run:
deactivate
Conclusion
Overall, we have shown you how to install pip on Ubuntu 22.04 and how to use it to manage Python packages.
In summary, by following this guide, you can:
- Install pip for Python 3 and Python 2
- Use pip to install, upgrade, and manage packages
- Install packages using a requirements.txt file
- Work with pip inside a virtual environment
Lastly, if you have any questions or feedback, feel free to comment below.
Information reviewed and updated: August 28, 2026.
Published by: REVOLD BLOG – blog.revold.us
Powered by AIR RISE INC & REVOLD AI
Sponsored: CORPIUS
Author: Roman Kravchina
Related Reading on Revold Blog
- How to install and configure Grafana on CentOS 9 or 10 or 11′
- How to set up an Ubuntu-based NAS
- How to Install Proxmox VE on Windows 8.3
- CentOS Automatic Updates Versions 9, 10, 11
- More Developing & Programming guides
- How to Install Jitsi Meet on Ubuntu/Debian with Automatic Let’s Encrypt SSL
- How to Install NGINX FastCGI Cache Purge Module Without Reinstalling NGINX on Ubuntu (Latest Versions)
- This guide will show you how to install a desktop (GUI) graphical interface on your Ubuntu server.
- How to Install Searx Search Engine on Ubuntu / debianArch LinuxFedora / RHEL
- How to Install NVIDIA Drivers on Ubuntu 22.04 LTS
- How to Install Jellyfin Media Server on Ubuntu 24.04
- How to Install Virtualmin on Ubuntu 22.04 or 24.04
- How to Install UniFi Controller on Ubuntu 22.04 or 24.04
- Install Docker Compose on Linux Ubuntu 22.04, Debian or up
- How To Install Docker Compose on Ubuntu 22.04
- How to Install a Desktop Environment/GUI in Ubuntu Server
- How to install Cockpit for Linux
- 20 Essential Python Concepts to Help You Become a More Effective Developer


