Signup/Sign In

Installing and Using pip on Ubuntu

Pip is a tool used to index, and install packages mainly from the Python Package Index (PyPI), but it can be used with other packages indexes as well.

Pip stands for "Preferred Installer Program", and is a python-based application for package management for the python programming language. It assists in managing libraries and dependencies, instead of doing them manually.

Python is available in 2 versions, 2 and 3. The default version being Python 3 for more recent distributions. Users still using Python 2, are advised to switch to Python 3.

When installing Python packages from apt, Python2 packages are prepended by a python2-, and Python3 packages with python3-.

When installing a python package, if you want to install globally it is generally advised to install the package available in the apt repo, since they are tested, and are secure deb packages.

Installing pip

To install pip, first, update your package repositories, and then install pip, using the following commands.

sudo apt update
sudo apt upgrade
sudo apt install python3-pip

Once installed to check for a successful install, run the following.

pip3 --version

The output may vary but it looks something like the following

pip3 version

Using pip

We will see a few basic commands and usage of pip, in this section. With pip, you can install packages from PyPI, version control, local projects, but we will mainly focus on PyPI.

To get a list of all commands supported by pip run

pip3 --help

pip3 help

For more information about a command, we can run pip3 <command> --help or pip3 <command> -h.

For example, to get help with install, we run

pip3 install -h

Installing a package

To install a package, you need to know the package name. Say for example you want to install the colorama package. The command would be as follows

pip3 install colorama # To install a specific version, say 0.4.0 write colorama==0.4.0

pip3 install

Installation using a Requirements file

requirement.txt is a text file used by python packages, listing dependencies and the required version numbers to run that project. To install using a requirements file, we can use the following command.

pip3 install -r requirement.txt

List install Packages

To list the packages, we run this command.

pip3 list

pip3 list packages

Upgrading a package

To upgrade a package, we need to install the package with the --upgrade/-U flag.

pip3 install -U colorama

pip3 upgrade

Uninstalling a Package

Pip packages can be uninstalled with the uninstall command in the following form.

pip3 uninstall colorama

pip3 uninstall


This tutorial covered how to install pip, and what it is. It also shows how to use pip for basic things, and how to install python packages on your Ubuntu.

About the author:
Pradeep has expertise in Linux, Go, Nginx, Apache, CyberSecurity, AppSec and various other technical areas. He has contributed to numerous publications and websites, providing his readers with insightful and informative content.