Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Python versions on the same machine?

Tags:

python

Is there official documentation on the Python website somewhere, on how to install and run multiple versions of Python on the same machine on Linux?

I can find gazillions of blog posts and answers, but I want to know if there is a "standard" official way of doing this?

Or is this all dependent on OS?

like image 517
Andriy Drozdyuk Avatar asked Mar 30 '10 18:03

Andriy Drozdyuk


People also ask

Can you have multiple versions of Python on your computer?

Install multiple python versions For Windows users, I recommend using the Windows x86-64 executable installer option if you work on a 64bit system. Otherwise, just use the Windows x86 executable installer . After locating the install option for the specific version, just press the download link.

What happens if I have 2 versions of Python?

There's nothing wrong with having two versions of python installed, and it's actually quite common to do so. Usually, one would install them with different names ( python vs python3 , for example) to avoid confusion though.

Can I install two versions of a Python package on the same computer?

With maven or gradle you can install two versions of the same package, with pip you cant. Still you cant use two versions of the same package in the same program.


1 Answers

I think it is totally independent. Just install them, then you have the commands e.g. /usr/bin/python2.5 and /usr/bin/python2.6. Link /usr/bin/python to the one you want to use as default.

All the libraries are in separate folders (named after the version) anyway.

If you want to compile the versions manually, this is from the readme file of the Python source code:

Installing multiple versions

On Unix and Mac systems if you intend to install multiple versions of Python using the same installation prefix (--prefix argument to the configure script) you must take care that your primary python executable is not overwritten by the installation of a different version. All files and directories installed using "make altinstall" contain the major and minor version and can thus live side-by-side. "make install" also creates ${prefix}/bin/python3 which refers to ${prefix}/bin/pythonX.Y. If you intend to install multiple versions using the same prefix you must decide which version (if any) is your "primary" version. Install that version using "make install". Install all other versions using "make altinstall".

For example, if you want to install Python 2.5, 2.6 and 3.0 with 2.6 being the primary version, you would execute "make install" in your 2.6 build directory and "make altinstall" in the others.

like image 71
Felix Kling Avatar answered Sep 30 '22 14:09

Felix Kling