How to install pip on Ubuntu 16.04


Pip is undoubtedly one of the most important component of python.

There are many ways to install Pip on Ubuntu 16.04. However, some methods available on the internet may cause you some troubles. For example, a popular method on the internet suggests this :

$ sudo apt-get install python-pip python-dev build-essential 
$ sudo pip install --upgrade pip 
$ sudo pip install --upgrade virtualenv

Well, this works since it installs pip and updated it to the latest version. However, the problem comes when you have two versions of python (2.x & 3.x) on your machine. Now

$ sudo pip install --upgrade pip

will combine the pip that python2.x uses with the pip of python3.x uses. From now on, using pip for python2.x is very troublesome. Asking

$ pip -V


$ pip3 -V

returns the same address of pip. (which is for python3.x)


So what is the correct way of installing it ?

First, install pip for python 2.x

$ sudo apt install python-pip

Second, install pip for python 3.x

$ sudo apt install python3-pip

Dont use pip install –upgrade on them. Just

$ sudo apt update && upgrade

will keep them updated. Now asking :

$ pip -V


$ pip3 -V

returns different address of pip. (which is for python3.x)

This is very handy in case you want to use pip to install a package then use that package with python 2.x instead of python3.x and vice versa.





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Powered by

Up ↑

%d bloggers like this: