Read in 3 minutes

last updated 

How to install Pip on Ubuntu 18.04

This tutorial is also available for:

centos 7 debian 9

Pip is a package management system that simplifies installation and management of software packages written in Python such as those found in the Python Package Index (PyPI). Pip is not installed by default on Ubuntu 18.04, but the installation is pretty straightforward.

In this tutorial, we will show you how to install Python Pip on Ubuntu 18.04 using the apt package manager. We will also walk you through the basics of installing and managing Python packages with pip.


Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges.

Installing pip for Python 3

Ubuntu 18.04 ships with Python 3, as the default Python installation. Complete the following steps to install pip (pip3) for Python 3:

  1. First update the package index by typing the following:

    sudo apt update
  2. Install pip for Python 3:

    sudo apt install python3-pip

    The command above will install Pip and all the dependencies required for building Python modules.

  3. Once the installation is complete, verify the installation with the following command which will print the pip version:

    pip3 --version

    The version number may vary, but it will look something like this:

    pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

Installing pip for Python 2

Python 2 is not installed by default in Ubuntu 18.04. If you want to install Python 2 and pip for Python 2, complete the following steps:

  1. Update the package index with the following command:

    sudo apt update
  2. Install pip for Python 2 with:

    sudo apt install python-pip

    The command above will install Python2, Pip and all the dependencies required for building Python modules.

  3. Verify the installation by printing the pip version number:

    pip --version

    The version number may vary, but it will look something like this:

    pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)

How to use pip

When installing python modules globally it is highly recommended to install distribution provided python modules using the apt package manager because they are tested to work properly on Ubuntu systems. Install python modules globally using pip only if there is no package available through the package manager

In most cases you should use pip within a virtual environments 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 of affecting other Python projects.

In this section we show you few useful basic pip commands. With pip we can install packages from PyPI, version control, local projects, and from distribution files but in most cases you will install packages from PyPI.

To view the list of all pip commands and options, type:

pip3 --help

To get more information about a specific command use pip <command> --help. For example to get more information about the install command, run:

pip install --help

Install a Package With Pip

To install the latest version of “package_name”:

pip3 install package_name

To install a specific version of “package_name”:

pip3 install package_name==2.3

Replace pip3 with pip if using Python 2.

Install Packages from Requirements Files With Pip

Requirement files is a file that contains a list of packages to be installed using pip. The file is mostly called requirements.txt. Use the following command to install a list of requirements specified in a file:

pip3 install -r requirements.txt

Upgrade a Package With Pip

To upgrade an already installed package to the latest version:

pip3 install --upgrade package_name

Uninstall a Package With Pip

To uninstall a package run:

pip3 uninstall package_name


In this tutorial, you have learned how to install pip on your Ubuntu machine and how to manage Python packages using pip. For more information about pip, visit the pip user guide page.

If you have any questions or feedback, feel free to comment below.