Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to install the Pillow module for python 3.3, but for that I need to install pip. Every time that I install pip it installs for python 2.7, any help?

share|improve this question
up vote 61 down vote accepted

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 overwrite /usr/bin/pip, because it will install a python3 based /usr/local/bin/pip which is also in Ubuntu 12.04's $PATH.

Instead of risking that, it's probably best to start investigating the happy world of virtualenv as this answer suggests, but alternatively you can rename the resulting 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
share|improve this answer
I have already tried that but this always shows up: Unable to locate package python3-pip – BCasaleiro Jan 28 '14 at 19:38
@BCasaleiro Sorry, I should have checked. Updating the answer. – Oli Jan 29 '14 at 8:38
Thanks, it worked like a charm – BCasaleiro Jan 29 '14 at 11:06
This causes problems for some people, with non-world-readable files in /usr/local/lib/python3.2/dist-packages/. – Marius Gedminas Nov 21 '14 at 11:01
This is undoubtedly the best answer to the stated question, but if one is using a newer version of Ubuntu, dmeu answer below is more appropriate. – brandizzi Dec 2 '15 at 18:57

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

share|improve this answer
Not on Ubuntu 12.04 LTS. – Marius Gedminas Nov 21 '14 at 11:01
@MariusGedminas Then maybe you shouldn't be exclusively using an outdated repository. Even if precise is still supported, that doesn't necessarily mean it has the latest software. It just means that they're keeping it online, on the "official repo", rather than moving it to the "old repo" where apt-get won't be able to access it; so that your package manager doesn't break. Case in point: I tried it, and it works fine; my sources.list uses the trusty repo, which can be used in 12.04 by just making a few additions to your sources.list and performing an apt-get update. – Braden Best Jan 29 '15 at 16:45
Also note the anaconda possibility – dmeu May 4 at 16:54
this is useful when you want to install pip3 globally – cyberbikepunk May 12 at 23:35

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:

share|improve this answer

After installing python 3.3 using a PPA for Ubuntu 12.04, I installed easy_install 3.3 using locally using the following commands

python3.3 -m distribute_setup install --user
easy_install-3.3 --user pip

This avoids polluting the site's installation of pip and easy_install. Finally, I added $HOME/.local/bin to my path. Now I can run pip3.3!

share|improve this answer

To add to dmeu's answer, you may have to update your /etc/apt/sources.list to include mirrors from a more recent repository, such as trusty.

sudo vi /etc/apt/sources.list
sudo apt-get update

To clarify on what Long-term support means, it does not necessarily mean that they are keeping precise up-to-date with the latest and greatest software. Sure, you will get a few updates from it, but then you'll have cases where certain packages don't exist, like python3-pip, which does exist in the trusty repo, for example.

What LTS means, is that they are keeping precise on the main repo, so that your package manager doesn't break. This will ultimately give you a chance perform an apt-get update, upgrade, and dist-upgrade when 12.04 finally becomes obsolete. They call it support, rather than cutting-edge, for a reason.

If the apt-get route still doesn't work, you may also try downloading a .deb package of python3-pip, and using dpkg, a.k.a. the debian package manager, to install it

sudo dpkg -i <name-of-package>.deb

Hope this helps.

share|improve this answer

by now my favorite option is to install anaconda or miniconda for python3:

Any package can be installed by conda install package-name

If you need python2, you can create a virtual environment:

conda create -n python2 python=2.7 anaconda source activate python2

See details here:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.