如何使用apt-get在Debian 5.0(lenny)上安装Python 2.6?

经过一些挖掘和实验后,我想出了如何使用apt-getDebian 5.0上安装Python 2.6。 所以我认为最好把SF作为问题和答案。 我知道这可以手动build立和安装,但很多人喜欢使用apt-get (包括我自己)。

这是打破你的系统的好方法; 你将会把各种稳定的东西升级到不稳定的状态,从那时起,你将会遇到麻烦,因为Debian并不是devise成运行在一个半稳定和半稳定的系统上。

一个更好的方法是一个backport,但是显然将2.6回传给lenny并不简单。

使用Apt-Pinning。

我还不是很习惯这个概念,但它似乎基本上意味着你configuration你的Debian系统的方式,使得你可以直接使用apt来安装稳定的,testing的,未经testing的(以及潜在的其他库,如backports)软件包 – 不要打破(太多)系统的依赖关系,因为默认情况下它会使用稳定的,只有当你想要的时候,它会在其他的仓库中search。

这是一个非常好的,符合人体工程学和安全的方式,只是将Debian系统的某些部分更新到最新版本,而不会破坏系统的依赖性和全局稳定性。

关于Apt-Pinning的一个很好的教程: http : //jaqque.sbih.org/kplug/apt-pinning.html

我在一个专用的虚拟主机上使用Lenny和Plesk,这是我的configuration文件,在2012年1月11日发布:

apt.conf

 APT::Cache-Limit "16777216"; 

的sources.list

 #Stable deb http://ftp.de.debian.org/debian lenny main contrib non-free deb http://ftp.de.debian.org/debian-volatile lenny/volatile main contrib non-free deb http://ftp.de.debian.org/debian-security lenny/updates main contrib non-free #Proposed updates deb http://ftp.de.debian.org/debian lenny-proposed-updates main contrib non-free deb http://ftp.de.debian.org/debian-volatile lenny-proposed-updates/volatile main contrib non-free #Testing deb http://ftp.de.debian.org/debian testing main contrib non-free #Unstable deb http://ftp.de.debian.org/debian unstable main contrib non-free #Backports deb http://ftp.de.debian.org/debian-backports 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 http://autoinstall.plesk.com/debian/PSA10 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 

这些文件全部放在目录/ etc / apt /

然后,你可以使用apt-get python,它会直接在你的系统上安装Python 2.7的所有依赖项! 如果你想安装更新的版本(比如3.x),你可以尝试在我链接的页面中给出的build议,以强制查看其他存储库:

 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. 

更新:删除答案,因为它涉及到滥用能力。 实际上最好的方法是使用源代码来安装2.6(尽pipe这样做有点困难,不太可能使系统搞砸)。