pip
is a python package management command used to search, install, update, and remove Python packages or modules. Python packages are provided by the Python project officially under the pypi.python.org address. pip command simple operates over these packages by downloading, installing, and updating them. In this tutorial, we will learn how to install the pip command for Ubuntu distribution. This tutorial can be easily used for Ubuntu versions 20.04, 18.04, and 16.04 and future non-lts versions without any problem.
pip or pip2 or pip3
Python has two major versions named Python2 and Python3. Even the project tries to make them compatible these versions have some incompatibilities. So in order to work Python2 or Python3, they should use different pip commands.
- pip command refers to the current default or active version of the Python2
- pip2 command refers to the Python2 and used to manage Python2 packages.
- pip3 command refers to the Python3 and used to manage Python2 packages.
Install pip3 For Python3
Ubuntu and other deb based distributions provides the pip3 command with the name of python3-pip
package. As you can see the pip3 command is provided with the Python3. Before install we will display python3-pip package information with the apt show command.
$ apt show python3-pip

From the pip package information that the pip version is 20.0.2.
Now we will install the pip3 command for the Python3 with the following apt command. We will also provide sudo command to provide root privileges.
$ sudo apt install python3-pip
After installating the pip3 we can check the version of the pip3 command by using --version
or -V
options like below.
$ pip3 -V
$ pip3 --version
Help information about the pip3 command can be printed with the -h
or --help
options like below.
$ pip3 -h
$ pip3 --help
Install pip For Python2
As a Python2 package manager pip2 is named as python2-pip
in the Ubuntu, Debian, Mint and Kali repositories. This package information can be displayed like below.
$ apt show python-pip
We can install pip2 or pip for the Python2 like below.
$ sudo apt install python-pip
The preciese version of the pip2 command can be shown like below.
$ pip -V
$ pip --version
Search and Install Python Packages with pip, pip2, and pip3 Command
After instaling pip 3rd party Python packages like numpy, django etc. can be easily installed with a little effort. First we will search a package in the pip repository with the search
parameter.
$ pip3 search django

Now we can show Python package information or details with the show
command like below.
$ pip3 show numpy

and we change install the numpy
package with the install
command like below.
$ pip3 install numpy