How to install Python Pip on Ubuntu 18.04 Server

This post describes how you can install Python Pip on ubuntu 18.04.

Why apt doesn’t work immediately

By default the server edition of Ubuntu only includes the main repository for the Ubuntu software. This is for various performance and security reasons but means that there are a number of packages that don’tĀ fit into this realm.

To be able to install pip you will need to configure an additional set of repositories to download it.

Configuring the Universe repositories

As an administratorĀ or by using sudo you will need to edit /etc/apt/sources.list. This will allow for the list of apt sources to be configured. For example you can run the below command to edit the file.

sudo nano /etc/apt/sources.list

If this is a clean install of Ubuntu 18.04 server this file will likely contain the following lines.

deb bionic main
deb bionic-security main
deb bionic-updates main

To add the universe repositories you need to add universe to the end of each line. Your modified file should look like the following.

deb bionic main universe
deb bionic-security main universe 
deb bionic-updates main universe

Once this has been done, save the file using Ctrl-O if you are using Nano.

Now you can update apt, and then install python-pip.

sudo apt update
sudo apt install python-pip

In addition to pip, this will allow installation of many other packages.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.