Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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).

share|improve this question
up vote 5 down vote accepted

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.

share|improve this answer
My answer thoroughly broke my system -- dependency mismatch ahoy! I will try pinning next time. – nbolton Jun 30 '10 at 22:44

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:

I am using Lenny with Plesk on a dedicated virtual host, here's my config files, made on 2012-01-11:


APT::Cache-Limit "16777216";


deb lenny main contrib non-free
deb lenny/volatile main contrib non-free
deb lenny/updates main contrib non-free

#Proposed updates
deb lenny-proposed-updates main contrib non-free
deb lenny-proposed-updates/volatile main contrib non-free

deb testing main contrib non-free

deb unstable main contrib non-free

deb lenny-backports main contrib non-free

#Plesk (? what does it do? install additional modules from the webinterface?)
#Uncomment the next line only if you have Plesk installed.
#deb lenny all


Package: *
Pin: release a=stable
Pin-Priority: 700

Package: *
Pin: release a=lenny-proposed-updates
Pin-Priority: 650

Package: *
Pin: release a=testing
Pin-Priority: 600

Package: *
Pin: release a=unstable
Pin-Priority: 550

Package: *
Pin: release a=lenny-backports
Pin-Priority: 500

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:

apt-get install <package>/unstable
#This will install the unstable version of the package, and try to meet any dependencies from Stable.


apt-get -t unstable install <package>
#This will install the Unstable version of the package, and try to meet any dependencies from Unstable.
share|improve this answer

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).

share|improve this answer
Unstable will always be sid, not just currently. If you are going to include testing packages, you might also want to setup pinning (, so you only get the packages from unstable that you really need. – Zoredache Feb 9 '10 at 23:59
Since this answer perfectly describe how to break your system and if one doesn't thoroughly reads the other answer and commits, it's – mark Oct 23 '10 at 12:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.