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?
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
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:
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:
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
easy_install. Finally, I added
$HOME/.local/bin to my path. Now I can run
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
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.
by now my favorite option is to install
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
Adding universe to the repositories does the trick.
Here I found it:
Blockquote You have to enable universe category which contains python-pip package.
/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
sudo apt update
sudo apt install python-pip
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