How to Install Pip on Ubuntu 18.04 LTS

pip pip
Ubuntu Ubuntu
Ubuntu 18.04 Ubuntu 18.04
Ubuntu 18.04 LTS Ubuntu 18.04 LTS

Pip is the standard package manager for the programming language Python. Pip drastically simplifies the process of installing and manage open source Python packages. All available Python packages can be browsed at (the Python Package Index), and if you end up publishing your own open source Python package they will be available here for other developers as well. All packages available via can be reach with the pip command line.

Tough, this tutorial is not primarily about pip, but rather on how to install pip on Ubuntu 18.04, so let's get started.

Requirements for Installing Pip on Ubuntu 18.04

  • A Machine running Ubuntu 18.04 (Server/Desktop)
  • Sudo Privilege for that machine

Installing Pip on Python 3

Lets make sure that you machine is up-to-date by running the update command.

sudo apt update

When everything is updated we can go ahead and install pip.

sudo apt install python3-pip

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

Installing pip for Python 2

Some of you might still be interested in running pip for Python 2.7 which is not installed on Ubuntu 18.04 by default.

Make sure that your system is up-to-date

sudo apt update

When everything is updated we can go ahead and install Python 2, the command is almost identical to the Python 3 installation (just remove the 3).

sudo apt install python-pip

And same as before, always verify that the installation was successful by running --version command.

pip --version

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

That's all that is necessary to get pip running on Ubunutu 18.04 for Python 2 or Python 3.

Pip Basics

If you are in the process or building your own app or starting a project It's advisable to not install your packages globally.

Python comes with virtual environments which makes it really easy to spin up an environment which is specially contained for a project in mind.

Start a virtual environment on Mac or Linux (Unix)

python3 -m venv projectname

Start a virtual environment on Windows

py -m venv projectname

I won't go more into details on how to use virtual environments in this tutorial but I thought you aught to know, so you don't start install packages globally.

The best way to get a better understanding of pip quickly is by running --help flag.

pip --help

here is an output of all the commands you can use to learn more about pip and its command-line interface.

  pip <command> [options]

  install                     Install packages.
  download                    Download packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  check                       Verify installed packages have compatible dependencies.
  config                      Manage local and global configuration.
  search                      Search PyPI for packages.
  wheel                       Build wheels from your requirements.
  hash                        Compute hashes of package archives.
  completion                  A helper command used for command completion.
  debug                       Show information useful for debugging.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  --isolated                  Run pip in an isolated mode, ignoring environment variables and user configuration.
  -v, --verbose               Give more output. Option is additive, and can be used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output. Option is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging levels).
  --log <path>                Path to a verbose appending log.
  --proxy <proxy>             Specify a proxy in the form [user:passwd@]proxy.server:port.
  --retries <retries>         Maximum number of retries each connection should attempt (default 5 times).
  --timeout <sec>             Set the socket timeout (default 15 seconds).
  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.
  --trusted-host <hostname>   Mark this host or host:port pair as trusted, even though it does not have valid or any HTTPS.
  --cert <path>               Path to alternate CA bundle.
  --client-cert <path>        Path to SSL client certificate, a single file containing the private key and the certificate in PEM format.
  --cache-dir <dir>           Store the cache data in <dir>.
  --no-cache-dir              Disable the cache.
                              Don't periodically check PyPI to determine whether a new version of pip is available for download. Implied with --no-index.
  --no-color                  Suppress colored output

The --help flag can be used after any pip command to get a deeper understanding of its particular use-case.

pip install --help

Did You Enjoy the Tutorial?

Consider sending some love to Freddie the creator.

Comments (0)

You need to be logged in to comment..

Topics Mentioned in this Tutorial

Pip is a package-managment system used to install and manage Python software packages. In the Python community, pip is seen as the de facto standard even though there are other alternatives around. Together with the Python Package Index, pip makes browsing, managing, distributing and install open-source Python packages a breeze....
Ubuntu is the most popular free and open source Linux distribution and is used across servers as well as desktop computer and mobile phones. Ubuntu is created by Canonical LTD and the open source community....
Ubuntu 18.04
Ubuntu 18.04 LTS
Ubuntu 18.04 LTS is a Long Term Support version of the free and open source Linux distribution Ubuntu. The operating system was released on 26th April 2018 and has a 3 year continued support cycle after the initial release. The Ubuntu LTS versions are used by people who want to run a secure desktop or server with continued support throughout its lifespan. The downside of using an Ubuntu LTS version is that you miss out on new feature releases. However, many see this a fair trade-of for running a secure and stable system with continued security updates....