6

Because I totally screwed up my python installation I manually deleted all the python files and am now trying to reinstall it.

When I type apt-get install --reinstall python2.7, I get this error message:

0 to upgrade, 0 to newly install, 1 reinstalled, 0 to remove and 0 not to upgrade.
3 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up python-minimal (2.7.3-0ubuntu2.2) ...
/var/lib/dpkg/info/python-minimal.postinst: 4: /var/lib/dpkg/info/python-minimal.postinst: python2.7: not found
dpkg: error processing python-minimal (--configure):
 subprocess installed post-installation script returned error exit status 127
Setting up python2.7 (2.7.3-0ubuntu3.4) ...
/var/lib/dpkg/info/python2.7.postinst: 6: /var/lib/dpkg/info/python2.7.postinst:     
 python2.7: not found
dpkg: error processing python2.7 (--configure):
 subprocess installed post-installation script returned error exit status 127
dpkg: dependency problems prevent configuration of python:
 python depends on python2.7 (>= 2.7.3); however:
  Package python2.7 is not configured yet.
  python depends on python-minimal (= 2.7.3-0ubuntu2.2); however:
  Package python-minimal is not configured yet.
dpkg: error processing python (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates it's a follow-up error from a previous failure.
                                                                                                        Errors were encountered while processing:
 python-minimal
 python2.7
 python
E: Sub-process /usr/bin/dpkg returned an error code (1)

How do I recover from this?

Edit: Further to kubahaha's suggestion, I tried

# dpkg -P python2.7

and it didn't work because of dependencies. This did remove the packages:

# dpkg -P libapache2-mod-wsgi libpython2.7 python2.7

But then when I tried:

# apt-get install python2.7 libapache2-mod-wsgi libpython2.7

I got this error message:

/var/lib/dpkg/info/python-minimal.postinst: 4: /var/lib/dpkg/info/python-minimal.postinst: python2.7: not found                                                                         
dpkg: error processing python-minimal (--configure):                                        
 subprocess installed post-installation script returned error exit status 127               
Errors were encountered while processing:
 python-minimal
E: Sub-process /usr/bin/dpkg returned an error code (1)

dpkg/apt seem to me to be very fragile in that once the system is in a bad state, they don't seem to ever be able to put themselves back into a good state.

1
  • Is your problem solved?
    – kubahaha
    Feb 27, 2014 at 19:21

1 Answer 1

1

Purge it and then install again

  1. sudo dpkg -P python2.7
  2. sudo apt-get install python2.7
4
  • I tried this; I could delete the packages but not reinstall them. See my comments in the main text above.
    – Phil Hunt
    Feb 26, 2014 at 21:34
  • IMO best way to fix is to delete everything what makes problems :-) So try also sudo dpkg -P python-minimal then sudo apt-get autoremove && sudo apt-get clean sudo apt-get update && sudo apt-get -f It's a killer-set :p
    – kubahaha
    Feb 26, 2014 at 21:39
  • 3
    @kubahaha: Ok, I just learned not to blindly copy commands without understanding. I just bricked my ubuntu since apparently all ubuntu packages depend on python and sudo apt-get autoremove removes everything =(
    – justhalf
    Oct 28, 2016 at 6:36
  • This final comment should be marked in BOLD, RED. There are python packages used for many things (from printers, to gtk, and beyond) in Ubuntu and so don't think you can reinstall python. This is the motivation for things like snap, where we can "containerize" (I'm not sure this is accurate but portrays the point) applications.
    – Just_Alex
    Jan 14, 2020 at 3:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .