How To Install Pip On Ubuntu 18.04, Debian 9 & Linux Mint 19

0

ADVERTISEMENT

Pip (Pip Installs Packages) is a package management system that allows you to install software packages written in Python. It is used to install packages listed in the Python Package Index (PyPI).

Pip is not installed on Ubuntu 18.04, Debian 9 and Linux Mint 19 by default. The installation of Pip on Ubuntu or Debian or Linux Mint is really easy.

In this post, we will see how to install Pip for Python 2 and Python 3 on Ubuntu 18.04, Debian 9 and Linux Mint 19. Apart from Pip installation, we will also see how to manage Python packages with pip.

Prerequisites

You must be logged into a system as the root user or a user with sudo privileges.

Install Pip for Python 3

Python 3 is installed by default in Ubuntu 18.04, Debian 9 and Linux Mint 19. Use the command below to verify.

python3 --version

Output:

Python 3.6.7

The above output shows that you have Python 3 installed.

We will now install the python3-pip package using the following commands.

sudo apt update
sudo apt install python3-pip

The above command will install pip for Python3 and its dependencies.

Once the pip installation is complete, verify the installation by checking its version.

pip3 --version

Output:

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

The above output confirms that the pip for Python 3 is successfully installed. The pip version may vary depending on the operating system and the date of release.

Install pip for Python 2

By default, Python 2 is not installed in Ubuntu 18.04, Debian 9 and Linux Mint 19. If you want to install Python 2 and pip for Python 2, you can follow the below steps.

sudo apt update

sudo apt install python-pip

The above command will install Python and pip for Python 2 and its dependencies.

Once the pip installation is complete, verify the installation by checking its version.

ADVERTISEMENT

pip --version

Output:

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

The above output confirms that the pip for Python 2 is successfully installed on Ubuntu. The pip version may vary depending on the operating system and the date of release.

How to Use Pip

We will go through some basics of Pip command usage.

Replace pip3 with pip in your commands if you are using Python 2.

Install Packages Using Pip

To install a package using Pip, you can use the below command.

pip3 install PACKAGE_NAME

For example, to install the latest version of the package called IPython, a powerful interactive Python shell, use the below command.

pip3 install IPython

This command will download all the necessary files and install the specified package.

To install a specific version of the package, you can run the below command.

pip3 install IPython==6.0

List Installed Pip Packages

To list the installed packages, use the below command.

pip3 list

Output:

.       .       .

httplib2 (0.9.2)
idna (2.6)
ipython (7.5.0)
ipython-genutils (0.2.0)
jedi (0.13.3)
keyring (10.6.0)

.      .       .

Upgrade Package Using Pip

To upgrade an installed package to the latest version, use the below command.

pip3 install --upgrade IPython

Remove Package Using Pip

If you want to remove a package installed via pip, you can use the below command.

pip3 uninstall IPython

Search Packages using Pip

If you want to find out a package name, you can use the Pip’s search functionality. This command will get the packages list from the PyPI (Python Package Index).

pip3 search google

Output:

google (2.0.2) - Python bindings to the Google search engine.
oauthkit-google (0.1.2) - OAuthKit for Google
bits-google (1.8.6) - BITS Google
google-gax (0.16.0) - Google API Extensions
google-finance (0.1.0) - Google Finance API
google-oauth (1.0.1) - OAuth2 for Google APIs
google-auth (1.6.3) - Google Authentication Library

.     .     .

Conclusion

In this post, you have seen how to install Pip on Ubuntu 18.04, Debian 9 and Linux Mint 19 and its command syntax to manage Python packages using Pip. You can visit Pip’s user guide page for more information about Pip.

You might also like