6

I have both python versions installed on my linux:

[/usr/bin] ls -la | grep python

python -> python3
python-config -> python3-config
python2
python3
python2-config
python3-config

I need to launch program which use a python to do some work. I cannot change this program and I don't know how it works, but I want it use python2.

As I see I can do it if I change python and python-config links. Is there any better way to do it ?

I have not found how to use different versions of python with virtualenv. May be there is something like rvm in ruby ?

ceth
  • 44,198
  • 62
  • 180
  • 289

1 Answers1

5

You can use specific version of Python with virtualenv like this -

virtualenv -p /usr/bin/python2 <path/to/new/virtualenv/>

This way the virtualenv would use Python 2.x version installed on your system.

PS: DON'T alter the symlinks between Python 2 and 3 manually. Might break your system.

Bibhas Debnath
  • 14,559
  • 17
  • 68
  • 96