How to Install Python Pip on Ubuntu 22.04
This guide explains how to install pip for Python 3 and Python 2 on Ubuntu 22.04 and the basics of installing and managing Python pip.
Table of contents
Pip is a package manager for Python used to install, upgrade, configure and manage project dependencies. With pip, you can search, download, and install packages from Python Package Index (PyPI) and other package indexes.
Before You Begin
Python comes in two flavors; Python 2 and Python 3. Python 3 is included in the base system installation, and Python 2 can be installed from the default ubuntu repositories. Users are encouraged to use Python 3.
Generally, when installing a Python module globally, you should prefer installing the module’s deb package with the apt
tool as they are tested to work properly on Ubuntu systems. Use pip to install a module globally only if there is no deb package for that module.
Python 3 packages are prefixed with python3-
, and Python 2 packages are prefixed with python2-
.
You should prefer using pip within a virtual environment only. Python Virtual Environments allows you to install Python modules in an isolated location for a specific project rather than being installed globally. This way, you do not have to worry about affecting other Python projects.
Installing pip for Python 3
Installing pip for Python 3 on Ubuntu 22.04 is a straightforward process. Run the following commands as root or sudo user in your terminal: