Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple versions of python [duplicate]

Tags:

python

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 ?

like image 537
ceth Avatar asked Jan 06 '14 12:01

ceth


People also ask

Can I have 2 Python versions?

If you wish to use multiple versions of Python on a single machine, then pyenv is a commonly used tool to install and switch between versions. This is not to be confused with the previously mentioned depreciated pyvenv script. It does not come bundled with Python and must be installed separately.

How do I delete multiple versions of Python?

Navigate to Control Panel. Click “Uninstall a program”, and a list of all the currently installed programs will display. Select the Python version that you want to uninstall, then click the “Uninstall” button above the list – this has to be done for every Python version installed on the system.

Can you install multiple versions of Python package?

Switch between different versionsYou can repeat the above steps and install different versions of python as you want and set priority and use them as needed. To use these python versions with IDE, go to your IDE's interpreter settings and there you can see the different versions of python available on your system.

Can I install 2 Python versions in Windows?

By design, Python installs to a directory with the version number embedded, e.g. Python version 2.7 will install at C:\Python27\ , so that you can have multiple versions of Python on the same system without conflicts. Of course, only one interpreter can be the default application for Python file types.


1 Answers

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.

like image 124
Bibhas Debnath Avatar answered Sep 20 '22 16:09

Bibhas Debnath