How do I install packages with pip when there are multiple Python versions?

You have two options, but either way, you need to get easy_install-3.2. Since it doesn't seem to be packaged, you have to install it yourself. Fortunately that's easy. And you should also get python3-pkg-resources, which is packaged:

sudo apt-get install python3-pkg-resources
wget http://python-distribute.org/distribute_setup.py
sudo python3 distribute_setup.py

Now you can just use easy_install-3.2 to install Pyramid, or go ahead and install pip in Python3.

OPTION 1:

sudo easy_install-3.2 pyramid

OPTION 2:

sudo easy_install-3.2 pip
sudo pip-3.2 install pyramid

Alternatively, if you want to install specific version of the package with the specific version of python, this is the way

 sudo python2.7 -m pip install pyudev=0.16

If the "=" doesnt work, use "=="

 sudo python2.7 -m pip install pyudev=0.16

Ouput: Invalid requirement: 'pyudev=0.16' = is not a valid operator. Did you mean == ?

 sudo python2.7 -m pip install pyudev==0.16

works fine


Each python binary should have its own pip executable.

You get one automatically if you use virtualenv. Then you could just run pip install pyramid in an activated virtualenv e.g.:

$ vex venv pip install pyramid

If you want to use pip to install for a system python3 then you could install pip for it:

$ sudo apt-get install python3-pip

It installs pip3 program. Then:

$ pip3 install --user pyramid

installs pyramid in ~/.local directory tree.

If you need to test a Python package on several python versions; you could use tox.

Tags:

Python

Pip