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 ?
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With