不能重新安装python2.6

我试图重新安装python2.6在Debian 6,但我得到:

root@ff: apt-get install --reinstall python2.6 Reading package lists... Done Building dependency tree Reading state information... Done You might want to run 'apt-get -f install' to correct these: The following packages have unmet dependencies: python-pkg-resources : Depends: python (< 2.7) but 2.7.5-5 is to be installed python-setuptools : Depends: python (< 2.7) but 2.7.5-5 is to be installed E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution). 

请注意,启动python2.6正常工作:

 :~$ python2.6 Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 

但是,我需要使用的应用程序依赖于现在已经破解的python,例如pip:

 ~$ pip Traceback (most recent call last): File "/usr/bin/pip", line 7, in <module> from pip.log import logger ImportError: No module named pip.log 

我以前安装python2.7并使用:

update-alternatives –config python

切换回2.6.但似乎安装使用Python 2.6的应用程序已被2.7安装损坏。

我试图卸载python2.7。 但它说,它没有安装,即使我可以从一个terminal启动它:

 # apt-get purge python2.7 Reading package lists... Done Building dependency tree Reading state information... Done Package python2.7 is not installed, so not removed 0 upgraded, 0 newly installed, 0 to remove and 460 not upgraded. # python Python 2.7.6 (default, Jan 11 2014, 14:34:26) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 

似乎需要完整的系统重新安装,但如果可能,我想避免这种情况。

还尝试恢复旧的状态文件:

 # cp /var/backups/dpkg.status.2 /var/lib/dpkg/status # apt-get clean # apt-get update 

和我的/ etc / apt / sources列表一样:

 # deb cdrom:[Debian GNU/Linux 6.0.4 _Squeeze_ - Official amd64 NETINST Binary-1 20120129-00:39]/ squeeze main #deb cdrom:[Debian GNU/Linux 6.0.4 _Squeeze_ - Official amd64 NETINST Binary-1 20120129-00:39]/ squeeze main deb http://ftp.se.debian.org/debian/ squeeze main deb-src http://ftp.se.debian.org/debian/ squeeze main deb http://security.debian.org/ squeeze/updates main deb-src http://security.debian.org/ squeeze/updates main # squeeze-updates, previously known as 'volatile' deb http://ftp.se.debian.org/debian/ squeeze-updates main deb-src http://ftp.se.debian.org/debian/ squeeze-updates main deb http://mirror.cse.iitk.ac.in/debian/ testing main contrib 

现在我尝试安装python-twisted我得到:

 # apt-get install python-twisted Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: iso-codes libserf-0-0 python-apt-common lsb-release Use 'apt-get autoremove' to remove them. The following extra packages will be installed: cpp-4.4 g++-4.4 gcc-4.4 gcc-4.4-base gcc-4.8-base libapr1 libapr1-dev libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-dev libaprutil1-ldap libc-dev-bin libc6 libc6-dbg libc6-dev libc6-i386 libdb5.1 libexpat1 libexpat1-dev libffi6 libgcc1 libgmp10 libgomp1 liblzma5 libmpfr4 libpython-dev libpython-stdlib libpython2.7 libpython2.7-dev libpython2.7-minimal libpython2.7-stdlib libsasl2-2 libsasl2-modules libsasl2-modules-db libsctp-dev libsctp1 libserf-1-1 libsqlite3-0 libsqlite3-dev libssl1.0.0 libstdc++6 libstdc++6-4.4-dev libsvn1 libtinfo5 libxml2 linux-headers-2.6.32-5-common locales make multiarch-support python python-crypto python-dev python-libxml2 python-lxml python-minimal python-openssl python-pkg-resources python-setuptools python-sqlite python-support python-svn python-twisted-bin python-twisted-conch python-twisted-core python-twisted-lore python-twisted-mail python-twisted-names python-twisted-news python-twisted-runner python-twisted-web python-twisted-words python-yaml python-zope.interface python2.7 python2.7-dev python2.7-minimal subversion 

上面的列表包含了一堆python2.7依赖关系….他们从哪里来? python2.6应该不可能安装python-twisted?

这是非常糟糕的方法来安装python2.7该Debian框,因为2.6是该操作系统的默认一个。 你很可能会打破依赖于/ usr / bin / python指向该版本的定义和testing版本的Python的脚本。 还有你安装2.7的方法,你最终升级了一些系统库以及2.6版本依赖的库。 在这一点上,这个系统很难被打破。

如果你想安装2.7而不打破操作系统,从源代码安装并使用virtualenv。 谷歌的步骤。

你安装了错误的python 2.7包。 除非你知道并且很好地理解你在做什么,否则你不能混合不同版本的软件包(在这里挤压和喘息)。 你的select是从wheezy完全删除python 2.7包,并最终重新安装python 2.6来解决它; 或升级整个系统喘息,摆脱python 2.6。 请注意,不应该有任何与Python 2.7的兼容性问题。

当然你也可以从源代码安装,或者像Danila那样创build一个虚拟环境或者chroot,但是这些都是我不推荐的,但是对于经验丰富的系统pipe理员来说是非常复杂的工作。 如果你想这样做的话,当然绝对有必要首先在testing系统上尝试它,并且只有在了解过程的时候才将其部署到生产环境中。