After some digging and experimentation, I figured out how to install Python 2.6 on Debian 5.0 using apt-get
. So I thought it best to post on SF as a question and answer. I know this can be manually built and installed, but many people prefer to use apt-get
(including myself).
This is a good way to break your system; you'll wind up upgrading all sorts of stable things to unstable, and you'll have trouble from then on, because Debian isn't designed to run on a system that's halfway stable and halfway unstable.
A better way is a backport, but it's not straightforward to backport 2.6 to lenny apparently.
Use Apt-Pinning.
I'm not yet very used to this concept, but it seems to basically means that you configure your Debian system in a way such that you can install packages from stable, testing, untested (and potentially other repositories such as backports) directly using apt-get, without breaking (too much) the dependencies of the system, because by default it will use stable, and only when you want it it will search in the other repositories.
This is a very nice, ergonomic and safe way to update only some parts of a Debian system to the latest releases, without breaking the dependencies and the global stability of the system.
A nice tutorial about Apt-Pinning: http://jaqque.sbih.org/kplug/apt-pinning.html
I am using Lenny with Plesk on a dedicated virtual host, here's my config files, made on 2012-01-11:
apt.conf
sources.list
preferences
These files are all to be placed under the directory /etc/apt/
Then, you can just use apt-get python, and it will directly install python 2.7 on your system with all the dependencies! And if you want to install newer versions (such as 3.x), you can try the advices given in the page I've linked to force looking into other repositories:
or
Update: Removed answer, since it involves some abuse of aptitude. The best way is actually to install 2.6 using sources (though this is a bit harder, it's less likely to screw your system up).