How to install pip for python 3 in ubuntu 12.04 LTS

2018 Update: This is still attracting upvotes which worries me.

12.04 has been unsupported for about a year now. The best way you can install pip3 is by upgrading to a newer, supported version of Ubuntu. You have 3 LTS versions to pick from.


While on more modern versions of Ubuntu you could just sudo apt-get install python3-pip (and then use pip3), a Python 3 copy of pip was never packaged for 12.04.

Therefore you need to follow the more old fashioned install route with easy_install:

sudo apt-get install python3-setuptools
sudo easy_install3 pip

Now, there is every chance that this will clash with Python 2's pip and override /usr/bin/pip, because it will install a python3 based /usr/local/bin/pip which is also in Ubuntu 12.04's $PATH.

It shouldn't overwrite it so as long as you know that, it might be acceptable. However it might be best to start investigating the happy world of virtualenv as this answer suggests.

Alternatively you could rename the easy-installed python3 version of pip:

sudo mv /usr/local/bin/pip /usr/local/bin/pip-3

Then you can confirm your existing pip is still python2.7 based:

pip --version

You may also install it by sudo apt-get install python3-pip and then call it by pip3. Et voilà


If you work with several versions of python on the same machine, it might be useful to work with virtual environments. This allows you to work with as many instances of python you want, each with their own set of packages. This is very useful if you're working with several versions of python, and/or if your projects require different versions of the same package(s).

To set this up:

sudo pip install virtualenv 

This can be done with ANY pip, so also with the standard pip using python 2.7. Then, to make a virtual environment with python3 as the interpreter, do:

virtualenv my_py3 --python=/usr/bin/python3
source my_py3/bin/activate # to activate the python3 environemt

Then install any packages you might want using

pip install <package> # no sudo required now, as you're IN the virtual environment

To stop the virtual environment, simple type:

deactivate