How to Install pip in Ubuntu Linux

Installing third party python packages can be very difficult without a package manager that can work across multiple operating systems. Thankfully, there is a tool called pip which is a command line tool and the default package manager for Python.

pip is the tool used to install Python libraries, It's automatically finds, download and install python packages.

In this tutorial we are going to learn how to install python pip command in Ubuntu Linux.

Each version of python has its own pip package manager. In Ubuntu pip for python3 provides by the python3-pip package.

To install pip for Python3, execute:

sudo apt-get update
sudo apt-get install python3-pip

For python 2, install the python-pip package.

When managing libraries with pip command, you need to use a specific version of the command for specific python version.

In Ubuntu 16.04, For python version 3, you need to use pip3 command:

pip3 --version
pip 8.1.1 from /usr/lib/python3/dist-packages (python 3.5)

For version 2, just the pip command:

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

Using Ubuntu pip to download and install modules and packages

Now we can use pip or pip3, the Python Package Manager, to install various libraries that we wanted to work with. For example, following command will install Django on Ubuntu for Python 3.

pip3 install django

Ubuntu pip command can do more than installing packages, it can uninstall, search, list packages and etc..

If you want to remove a package that you are no longer using, run this:

pip uninstall package-name

To list installed libraries, run:

pip list

The search command will search for libraries that match the given keyword.

pip search django

The Ubuntu pip command get Third party packages from the python package index at