Install Python Pip on Ubuntu 19.04

How to install Python Pip on Ubuntu 19.04

Overview

In this tutorial, you will learn how to install Python Pip onto Ubuntu 19.04. The process is essentially the same as for Ubuntu 18.04.

Pip is a package management system for Python that allows you to install and manage software packages written in Python.

Installing Pip

Python Pip is available from the Ubuntu 19.04 source repositories, and it can easily be installed without additional work. The version available for Ubuntu 19.04 is 18.1.

Much like with Ubuntu 18.04 there are two versions of Pip supported in the source repos — a version for Python 2.7 and one for Python 3. The latter is the recommended version, as the former will be deprecated in the near future.

Install Python Pip for Python 3

To install Pip for Python 3, run the following command.

sudo apt install python3-pip

Install Python Pip for Python 2.7

To install Python Pip for Python 2.7, use the following command.

sudo apt install python-pip

Pip Installation Script

An alternative to installing Pip from the Ubuntu Apt repository is to run an installation script provided by pypa.com. This is useful for distribution that do not have Pip available in their package manager, or when you want more installation options.

Apt will not be aware of Pip when installed using this script. If Pip is already installed via Ubuntu’s package manager, installing it again using the installation script could put your server into an inconsistent state.

Download the installation script for Pip from pypa.com

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

Execute the script using Python

python get-pip.py

Updating Python Pip

Pip is capable of updating itself using the pip install command. When executed, Pip will look for an updated version of itself and then install it.

To update Pip, run the following command

pip install -U pip

Intalling Packages

To install a new package using Python Pip, the pip install command is used with the name of the package to be installed.

pip install PACKAGE_NAME

For example, to install Ansible through Pip you would run the following command.

pip install ansible

Update Installed Packages

Packages are frequently updated, and to ensure you are running the latest version that fix bugs, security vulnerabilities, or add new features, you use the pip install command with the -U flag.

pip install -U PACKAGE_NAME

For example, to update the Ansible package you would run the following command.

pip install -U ansible

Remove Installed Packages

To uninstall and remove packages from Ubuntu 18.04, the pip uninstall command is used.

pip uninstall PACKAGE_NAME

For example, to uninstall the Ansible package from Ubuntu 18.04 you would run the following command.

pip uninstall ansible

Listing All Installed Packages

To list packages installed using Pip, you can use the list command. The pip list command will output each install package with its version.

pip list

Listing All Outdated Packages

Keeping an eye on outdated packages is simply using the outdated list option. A nicely formatted list of outdated packages that are installed on the system by pip will be outputted.

pip list --outdated

Show Information about Install Package

To show detailed information about a package that is installed on the server, the pip show command can be used. Included in the output of this command is the package name, version, a short summary, and a dependency tree.

pip show <package name>