Debian – cannot reinstall python2.6

debianpython

I am trying to reinstall python2.6 on debian 6 but I get:

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

Notice that starting python2.6 works fine:

:~$ 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.
>>> 

But its the application that I need to use which depend on python that is now broken, e.g 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

I previously installed python2.7 and have used:

update-alternatives –config python

to switch back to 2.6.But it seems that application installed using python 2.6 has been corrupted by the 2.7 install.

I have tried to uninstall python2.7. But it says that its not installed, even though I can start it from a 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.
>>> 

It seems that a complete re-install of the system is required, but I would like to avoid that if possible.

And also tried restoring an older status file :

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

And my /etc/apt/sources list:

# 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

Now of I try to install python-twisted I get:

# 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

The above list contains a bunch of python2.7 dependencies….where do they come from? Should it not be possible to install python-twisted for python2.6?

Best Answer

This is extremely poor method to install python2.7 to that Debian box, since 2.6 is default one for that OS. You most likely will break scripts that rely on /usr/bin/python pointing to the defined and tested version of python for that release. Also with the way you installed 2.7 you ended up upgrading some system libraries as well which stock 2.6 version depends on. At this point it is quite hard to unbreak the system.

If you want to install 2.7 without breaking the OS, install it from source and use virtualenv. Google the steps.