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?
10 Answers
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

- 124
- 9

- 293,335
-
1This 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
-
1This 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 02 '15 at 18:57
-
1Don't do this. This hoses your install. pip8 wants python3.4 but this will put on python3.2 as a requirement for python3 setup tools and then you can't uninstall it when pip3 fails to run because of compatibility issues. It completely breaks everything. Here's notes to get you back to a stable place http://getpostdelete.com/unscrewing.txt (this is for LTR 12.04). Note that this won't run as a script. Read each comment and decide for yourself if you want to incur the involved risks. Been linuxing for 20 years but I make no claim that this solution is right for you. – kristopolous Feb 28 '16 at 01:02
-
why is it not able to locate the
package python3-pip
? I also have that issue and don't understand why or how to fix it. – Charlie Parker Dec 16 '16 at 03:17 -
1
sudo apt-get install python3-setuptools
andsudo easy_install3 pip
works fine on Ubuntu Trusty (14.04) ;-) – Maxwel Leite Aug 28 '17 at 22:09 -
1
-
1easy_install was removed from python-setuptools https://launchpad.net/ubuntu/+source/python-setuptools/39.0.1-2 – JBaczuk Sep 07 '18 at 20:54
-
@JBaczuk This answer was specifically for 12.04. 14.04 up have pip3 packages. 12.04 is long out of support so the only answer for it now is: *upgrade yesterday*. – Oli Sep 10 '18 at 08:58
-
Error I got: No local packages or download links found for pip error: Could not find suitable distribution for Requirement.parse('pip') – Rob Feb 05 '19 at 20:53
-
Ubuntu 12.04 might fail because it uses http instead of https for pypi. However, you can use: easy_install3 -i https://pypi.python.org/simple/ pip – PHZ.fi-Pharazon Aug 06 '22 at 17:26
You may also install it by sudo apt-get install python3-pip
and then call it by pip3
. Et voilà

- 819
-
15
-
2@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 thetrusty
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 -
1
-
-
@BradenBest not sure if this is true but it seems its the version of ubuntu in docker. What version should I be using? I am also having issues installing pip3 and wish to install it. – Charlie Parker Dec 16 '16 at 03:19
-
@CharlieParker the version of Ubuntu you should be using comes down to a matter of taste. Want to not have to deal with full LSB system updates as often to keep your package manager from breaking? Use the latest LTS release. Want the most recent Ubuntu? Use the most recent Ubuntu. As for pip3, unfortunately, that's going to be finicky no matter what repo you use. If apt-get won't do it, then maybe you're just better off building and installing python packages manually – Braden Best Dec 16 '16 at 07:19
-
I am getting
The command '/bin/sh -c apt-get install -qy python3-pip' returned a non-zero code: 100
when I do the command you suggested. Did you get that error message too? – Charlie Parker Jan 14 '17 at 01:26
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

- 1,673
- 1
- 15
- 23
After installing python 3.3 using a PPA for Ubuntu 12.04, I installed easy_install
3.3 using locally using the following commands
wget http://python-distribute.org/distribute_setup.py
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
!

- 430
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.

- 231
-
2On a fresh Ubuntu 18.04 LTS,
sudo apt-get install python3-pip
could not findpython3.pip
. Executingsudo apt-get update
then repeating the failed install worked. – David Ching Oct 17 '18 at 17:48 -
I tried following commands:
sudo apt-get update
sudo apt-get install python3-pip
This seemed to do the trick for me. I hope this helps others having the same issue.
Adding universe to the repositories does the trick.
Here I found it:
Blockquote You have to enable universe category which contains python-pip package.
Open /etc/apt/sources.list
using an editor
sudo nano /etc/apt/sources.list
then add universe at the end of each line, like this:
deb http://archive.ubuntu.com/ubuntu bionic main universe
deb http://archive.ubuntu.com/ubuntu bionic-security main universe
deb http://archive.ubuntu.com/ubuntu bionic-updates main universe
then run:
sudo apt update
and finally:
sudo apt install python-pip

- 211
by now my favorite option is to install anaconda
or miniconda
for python3: https://www.continuum.io/downloads
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: https://stackoverflow.com/a/24415581/551694
It is not available in older package manager versions.
Upgrade your package manager version using sudo apt update && sudo apt upgrade -y
and it works perfectly fine.
As of 2022/08 the main issues are
- PyPi has dropped support for http, so you need to use switch: -i https://pypi.python.org/simple/
- PyPi requires SNI support for https. You can find this out by checking out the error messages ~/.pip/pip.log
- Pip requires minimum Python 3.5, so valid upgrade alternatives are i) (as suggested by @allanlaal) use bionic packages ii) compile python from source or iii) use the following packages from legacy ppa deadsnakes + easy_install
The installation procedure:
echo |add-apt-repository ppa:fkrull/deadsnakes
apt-get update
apt-get -y install python3.5 python3-setuptools
rm /usr/bin/python3
ln -sf /usr/bin/python3.5 /usr/bin/python3
cd /opt
git clone https://github.com/pypa/setuptools.git
cd setuptools
git reset --hard 7ff173926c4773d39f3320ff0c9d65afb290e7b1 #50.3.2 - last version that supports python 3.5
python3 bootstrap.py
python3 setup.py install
easy_install3 -i https://pypi.python.org/simple/ pip==20.3.4

- 277
- 2
- 4
sudo apt-get install python3-pip
, however I get it can't find it. Did you have that problem too? Did you fix it? – Charlie Parker Dec 16 '16 at 03:26