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?
ベストアンサー1
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 usingmake 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 usingmake install
. Install all other versions usingmake 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 andmake altinstall
in the others.