Linux, Web Hosting, and Everything Else in Between
Linux, Web Hosting, and Everything Else in Between

How to Install Pip on Ubuntu

How to Install Pip on Ubuntu

In this tutorial, we’ll show you how to install Pip, the Python package manager on Ubuntu. We’ll also show you how to install Python (pip) packages and more.

This tutorial was tested and works on Ubuntu 20.04 and 18.04, but it will work on any other Ubuntu and Debian-based distros.

Requirements

This is what you need for this tutorial:

  • A sudo/root user.
  • An Ubuntu desktop or server. If you need a server, get one from Vultr or Linode. If you get a server from SolaDrive they will install Python and Pip for you.
  • Python 3. You can follow our tutorial if it’s not already installed.
  • Basic knowledge of the CLI/Terminal.

Update the system

As always, the first step to any tutorial is to update your Ubuntu system. You can do so with the following commands:

sudo apt-get update
sudo apt-get upgrade

Install Pip on Ubuntu

To install Pip for Python 3 on Ubuntu, simply run the following command:

sudo apt-get install python3-pip

To verify the installation you can run the following command:

pip3 -V

This should give you an output similar to this:

pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

Depending on what version you’re using.

How to install and update packages with Pip

If you want to use pip to install Python packages, just use the following command:

pip3 install <package-name>

For example, if you want to install NumPy, run the following command:

pip3 install numpy

If you have a list of packages like requirements.txt, you can run the following command to install them:

pip3 install -r /path/to/requirements.txt

The pip install command is also used for upgrading packages. So if you’d like to upgrade a pip package, you can do so with the following command:

pip3 install -U <package_name>

Or with a specific example, if you’d like to upgrade NumPy, run:

pip3 install -U numpy

If you’d like to remove a package, use the following command syntax:

pip3 uninstall <package_name>

Or, again, with the NumPy example, if you’d like to uninstall NumPy, run:

pip3 uninstall numpy

You can get the list of other commands and options for the pip command with:

pip3 -h

And if you’d like to get help for a specific command, use:

pip3 install -h

That’s all. You can now use pip to install and manage Python packages on Ubuntu.

Leave a comment

Your email address will not be published. Required fields are marked *