Pip is a package manager for Python that allows you to install and manage additional Python packages that are not part of the Python standard library. Pip makes it easy to install, upgrade, and remove Python packages. By default, Ubuntu 22.04 comes with Python 3 pre-installed but pip needs to be installed separately.
Table of Contents
In this guide, we will show you how to install pip (pip3) for Python 3 on Ubuntu 22.04 through the command line.
Prerequisites for Installing pip3 in Linux
Before you install
pip, make sure you have
Python 3 installed on your Ubuntu 22.04 system.
You can check the Python version by running:
The default Python 3 version on Ubuntu 22.04 is 3.10.
If you don’t have Python 3, you can install it with:
sudo apt install python3
You also need to make sure your system packages are up to date:
sudo apt update sudo apt upgrade
This will fetch the latest package lists and install any available updates. once the system is updated and Python 3 installed, follow the steps below to install pip3 in your computer.
Install Pip (pip3) in Ubuntu Linux
To install pip for Python 3, run:
sudo apt install python3-pip
This will install
pip along with any required dependencies.
Once the installation is complete, you can verify
pip is installed correctly by checking the version:
You should see the pip version displayed:
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)
The actual version number may vary, but this confirms that the pip is installed successfully in your computer and is ready for use.
Using Pip to install Python Packages
pip installed, you can start installing Python packages. For example, to install a package like Django:
pip3 install django
Pip will download and install django and its dependencies automatically.
To upgrade an already installed package using pip command, follow this:
pip3 install --upgrade django
This will update django to the latest version.
To uninstall a package using
pip3 uninstall django
You can also manage packages by creating a requirements.txt file that lists dependencies.
Commonly used pip commands you should know
Here are some of the common pip commands that are used in Python. It includes:
pip3 install– Install packages.
pip3 uninstall– Uninstall packages.
pip3 list– List installed packages
pip3 show– Show information about installed packages.
pip3 freeze– Output installed packages in requirements format.
pip3 search– Search PyPI for packages.
pip3 --help for more usage information.
Installing pip on Ubuntu 22.04 is straightforward since Python 3 is included by default. After updating packages and installing the python3-pip package, pip can be used to easily install and manage additional Python packages from PyPI.
Pip keeps your Python environment up to date with the latest versions of dependencies for your Python projects.