Background:
Given the background, how do you install a newer version of python and keep the older python version?
I have downloaded from python.org the "install from source" *.tgz package. The readme is pretty simple and says "execute three commands: ./configure; make; make test; sudo make install;"
If I do the above commands, will the installation overwrite the old version of python I have (I definitely need the old 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.
It can install multiple Python versions, specify the version that's used system-wide, and specify the version that's used in specific directories. It can also create and manage virtual environments using specific 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.
When you install from source, by default, the installation goes in /usr/local
-- the executable in particular becomes /usr/local/bin/pythonX.Y
with a symlink to it that's named /usr/local/python
. Ubuntu's own installation is in /usr/
(e.g., /usr/bin/python
), so the new installation won't overwrite it. Take care that the PATH
environment variable doesn't have /usr/local/bin
before /usr/bin
, or else simple mentions of python
would execute the new one, not the old one.
I'm just going to assume that by "newer version" you mean "released version that is newer than the default version in Ubuntu". That means python 3.1, which is in the repositories.
sudo apt-get install python3
Different python versions in the Ubuntu repositories can coexist with one another just fine. If you're on a version of Ubuntu older than Lucid, you'll have to upgrade your OS or enable the universe repository in order for python3 to show up in your package manager.
If you mean python 2.7, you should be aware that it hasn't been released yet.
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