25

I have different versions of python installed, python 2.7 being the default and 3.2 the second. Now I want to install pyramid to the 3.2 installation. How can I do this? Just using pip to install pyramid does not work, so how can I change the version it is downloading to?

5 Answers 5

10

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
1
  • When I run 'sudo python3 distribute_setup.py' it gives a syntax error. Perhaps it's out of date with python3.4 that I'm using?
    – AlanSE
    Nov 3, 2014 at 13:40
5

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

3

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.

2

If you get pip3.8 installed this way:

https://stackoverflow.com/questions/61717006/pip-for-python-3-8

More specifically:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3.8 get-pip.py

Then you can add this to your .bashrc file:

pip3.8() {
  python3.8 -m pip "$@"
}

After creating a new terminal session simply install packages with:

pip3.8 install xyz

Which will place your custom python packages in something like: /home/youruser/.local/lib/python3.8/site-packages

1

In the case where you have installed a separate user-only version of Python by downloading and extracting the tar.gz from the Python.org Downloads page and done a:-

tar -xzf Python-x.x.x.tar.gz
cd Python-x.x.x/
./configure
make

You can use get-pip to install and run pip for this Python install only.

Download it with curl as per the git-pip instructions. Then, within your Python-x.x.x/ directory, run:

./python -m get-pip.py --user
./python -m pip install pyramid --user

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .