thanasissdr
thanasissdr

Reputation: 817

How to install pip associated to different versions of Python

Currently, I am running two versions of python on Mac. The native one (2.7.10) (/usr/bin/python), and another one, which has been downloaded via home-brew (2.7.14).

I want to download two versions of pip and download packages depending on the python version I want to use.

Is this possible?

Upvotes: 1

Views: 2562

Answers (2)

gr8kodr
gr8kodr

Reputation: 1

It's worth mentioning (for Windows Users), once you have multiple versions of Python installed, you can easily manage packages for each specific version by calling pip<major>.<minor> from a cmd window.

for example, I have Python 2.7, 3.6 and 3.7 currently installed, and I can manage my packages for each installation using pip2.7, pip3.6 and pip3.7 respectively ...

On Windows 10, $ pip3.7 install <module> works for me - haven't tested it with venv instances yet though

Upvotes: 0

AlanK
AlanK

Reputation: 9853

Start by checking your available Python interpreters on your command line:

[root@server ~]# ls /usr/bin/ | grep python
python2 -> python2.6
python2.6
python3 -> python3.4
python3.4

Then download and run this file using each interpreter

[root@server ~]# python2.6 get-pip.py
[root@server ~]# python3.4 get-pip.py

Then once both Python interpreters have thepip module installed, you can install packages to your specific Python interpreters using the following commands:

[root@server ~]# python2.6 -m pip install <module>
[root@server ~]# python3.4 -m pip install <module>

Upvotes: 3

Related Questions