Is there any way to make pip
play well with multiple versions of Python? For example, I want to use pip
to explicitly install things to either my site 2.5 installation or my site 2.6 installation.
For example, with easy_install
, I use easy_install-2.{5,6}
.
And, yes — I know about virtualenv, and no — it's not a solution to this particular problem.
for example, if you set other versions (e.g. 3.5) as default and want to install pip for python 2.7:
pip is also a python package. So the easiest way to install modules to a specific python version would be below
or
So apparently there are multiple versions of
easy_install
andpip
. It seems to be a big mess. Anyway, this is what I did to install Django for Python 2.7 on Ubuntu 12.10:I had python 2.6 installed by default (Amazon EC2 AMI), but needed python2.7 plus some external packages for my application. Assuming you already installed python2.7 alongside with default python (2.6 in my case). Here is how to install pip and packages for non-default python2.7
Install pip for your python version:
Use specific pip version to install packages:
Most of the answers here address the issue but I want to add something what was continually confusing me with regard to creating an alternate installation of python in the
/usr/local
on CentOS 7. When I installed there, it appeared like pip was working since I could usepip2.7 install
and it would install modules. However, what I couldn't figure out was why my newly installed version of python wasn't seeing what I was installing.It turns out in CentOS 7 that there is already a python2.7 and a pip2.7 in the
/usr/bin
folder. To install pip for your new python distribution, you need to specifically tell sudo to go to/usr/local/bin
This should get pip2.7 installed in your
/usr/local/bin
folder along with your version of python. The trick is that when you want to install modules, you either need to modify the sudo$PATH
variable to include/usr/local/bin
or you need to executeif you want to install a new module. It took me forever to remember that
sudo
wasn't immediately seeing/usr/local/bin
.Context: Archlinux
Action:
Install python2-pip:
sudo pacman -S python2-pip
You now have pip2.7:
sudo pip2.7 install boto
Test (in my case I needed 'boto'):
Run the following commands:
Success: No error.
Exit: Ctrl+D