1

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?

5
  • How about throw everything (python related) out with --purge and then install again? Just an idea. I'm not an expert in apt, but maybe it helps. – Boris Däppen Jan 26 '14 at 15:17
  • Did you try doing what it told you to do? – Michael Hampton Jan 26 '14 at 17:12
  • Yes see the edited post. Its purge and not --purge – u123 Jan 27 '14 at 8:43
  • What do you get when you simply start python2.6? You say it's corrupted, but how did you determine that? – Tim Stoop Jan 27 '14 at 12:20
  • I updated my post with more clarification - its not python that is corrupted but the application that depends on it. – u123 Jan 27 '14 at 12:30
1

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.

0

You installed the wrong python 2.7 package. You mustn't mix packages from different releases (here squeeze and wheezy) unless you know and understand well what you are doing. Your options are either to remove entirely python 2.7 packages from wheezy, and eventually reinstall python 2.6 to fix it; or upgrade the whole system to wheezy and get rid of python 2.6. Note that there shouldn't be any compatibility problem with python 2.7 anyway.

You could of course also install from source or create a virtual environment or chroot as said Danila, however these are quite complex endeavours I wouldn't recommend but to seasoned system administrators. In case you'd want to go this way, it's of course absolutely necessary to first try it on a test system, and deploy it to production only when the process is well understood.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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