How to Install pip on Ubuntu 18.04

In this tutorial, we will show you how to install pip on an Ubuntu 18.04 VPS.

Pip is a package management system which can be used to install and manage packages written in Python. Python is a programming language that allows you to perform web development, software development, system administration, scientific and numeric data analysis, and much more. The Python Package Index (PyPI) hosts thousands of third-party modules for Python and you can install any of these modules using the pip package manager. Installing Pip on Ubuntu 18.04 is a very easy task, and if you follow our instructions carefully, you will have pip installed on your Ubuntu 18.04 VPS in just a few minutes. Let’s get started with the installation.

Prerequisites:

  • An Ubuntu 18.04 VPS
  • Access to the root account, or to a user with sudo privileges.

Step 1: Connect to the Server

To connect to your server via SSH as the root user, use the following command:

ssh root@IP_ADDRESS -p PORT_NUMBER

and replace “IP_ADDRESS” and “PORT_NUMBER” with your actual server IP address and SSH port number. You can use the username of an admin account in place of the word ‘root’ if needed.

Once logged in, make sure that your server is up-to-date by running the following commands:

apt update
apt upgrade

Step 2: Install pip for Python 3

Python 3 is the default version that comes with Ubuntu 18.04. To check if pip for Python 3 is already installed on your server, run the following command:

pip3 -V

If pip3 is not installed, you will get the following output:

Command 'pip3' not found, but can be installed with:

apt install python-pip3

We can now install pip3 by running the following command:

apt install python-pip3

After the installation is completed, you can now check again whether pip3 as been successfully installed with:

pip3 -V

If pip3 has been successfully installed, you should get the following output on your screen:

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

Step 3: Install pip for Python 2 (optional)

If you want to use Python 2 instead of the default Python 3 version on your Ubuntu 18.04 server, you can follow these instructions, instead.

First, check if pip (for Python 2) is installed on your server with:

pip -V

If pip is not installed, you will get the following output:

Command 'pip' not found, but can be installed with:

apt install python-pip

To install pip and Python 2 on your server, run the following command:

apt install python-pip

After the installation is completed, you can verify it with the following command:

pip -V

The following output should be displayed on your screen:

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

Step 4: Basic pip3 Commands

Now that you have successfully installed pip3 on your server, we will show you how to use it by going over a few basics.

The basic syntax for pip3 is the following:

pip3 <command> [options]

Here are some useful commands to help you get started with using pip3.

To search for a package, run the following command:

pip3 search package_name

To install a package:

pip3 install package_name

To list all installed packages:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS
pip3 list

To uninstall a package:

pip3 uninstall package_name

For more pip3 options and usage examples, you can run the following command:

pip3 --help

Usage:
pip <command> [options]

Commands:
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.
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.
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 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.
--disable-pip-version-check
                            Don't periodically check PyPI to determine
                            whether a new version of pip is available for
                            download. Implied with --no-index.

And if you want to get more information about any specific command, you can use the following command:

pip3 <command> --help

Congratulations – you now have an instance of Pip installed, and you know more about how to use it.


Of course, you don’t have to install pip on Ubuntu 18.04 if you use one of our Python VPS Hosting services, in which case you can simply ask our expert Linux admins to install pip on Ubuntu 18.04 for you. They are available 24×7 and will take care of your request immediately. We also published a post on How to Install pip on Ubuntu 20.04.

PS. If you liked this post on how to install pip on Ubuntu 18.04, please share it with your friends on the social networks by using the buttons below, or simply leave a reply down in the comments section. Thanks.

Here’s a link to our new version: How to install pip on Ubuntu 20.04.

Leave a Comment