Ubuntu – Python-problem-report python-apport apport break apt-get

apt

I can no longer install or upgrade packages with apt-get since the packages python-problem-report, python-apport and apport seem to cause some problems. Any apt-get command I have tried results in the following error message:

Preparing to replace python-problem-report 2.0.1-0ubuntu15.1 (using .../python-problem-report_2.0.1-0ubuntu15.1_all.deb) ...
  File "/usr/bin/pyclean", line 64
    except (IOError, OSError), e:
                             ^
SyntaxError: invalid syntax
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg - trying script from the new package instead ...
  File "/usr/bin/pyclean", line 64
    except (IOError, OSError), e:
                             ^
SyntaxError: invalid syntax
dpkg: error processing /var/cache/apt/archives/python-problem-report_2.0.1-0ubuntu15.1_all.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 36, in <module>
    from debpython.version import SUPPORTED, debsorted, vrepr, \
  File "/usr/share/python/debpython/version.py", line 24, in <module>
    from ConfigParser import SafeConfigParser
ImportError: No module named ConfigParser
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Preparing to replace python-apport 2.0.1-0ubuntu15.1 (using .../python-apport_2.0.1-0ubuntu15.1_all.deb) ...
  File "/usr/bin/pyclean", line 64
    except (IOError, OSError), e:
                             ^
SyntaxError: invalid syntax
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg - trying script from the new package instead ...
  File "/usr/bin/pyclean", line 64
    except (IOError, OSError), e:
                             ^
SyntaxError: invalid syntax
dpkg: error processing /var/cache/apt/archives/python-apport_2.0.1-0ubuntu15.1_all.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 36, in <module>
    from debpython.version import SUPPORTED, debsorted, vrepr, \
  File "/usr/share/python/debpython/version.py", line 24, in <module>
    from ConfigParser import SafeConfigParser
ImportError: No module named ConfigParser
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Preparing to replace apport 2.0.1-0ubuntu15.1 (using .../apport_2.0.1-0ubuntu15.1_all.deb) ...
apport stop/waiting
  File "/usr/bin/pyclean", line 64
    except (IOError, OSError), e:
                             ^
SyntaxError: invalid syntax
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg - trying script from the new package instead ...
  File "/usr/bin/pyclean", line 64
    except (IOError, OSError), e:
                             ^
SyntaxError: invalid syntax
dpkg: error processing /var/cache/apt/archives/apport_2.0.1-0ubuntu15.1_all.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
apport start/running
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 36, in <module>
    from debpython.version import SUPPORTED, debsorted, vrepr, \
  File "/usr/share/python/debpython/version.py", line 24, in <module>
    from ConfigParser import SafeConfigParser
ImportError: No module named ConfigParser
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/python-problem-report_2.0.1-0ubuntu15.1_all.deb
 /var/cache/apt/archives/python-apport_2.0.1-0ubuntu15.1_all.deb
 /var/cache/apt/archives/apport_2.0.1-0ubuntu15.1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

This happens even if I try to install packages that have nothing to do with the 3 trouble-making packages. I also selected "Lock at Current Version" in muon for these 3 packages, but the same error still occurs.

Any help would be greatly appreciated.

Best Answer

I found the problem. I had manually installed a newer version of python (version 3.2 but the version installed through packages is 2.7) and I just redirected /usr/bin/python to python3.2. Apparently in 3.2 some syntax used in /usr/bin/pyclean is not valid anymore. Restoring the original link of /usr/bin/python to /usr/bin/python2 solved the problem. Now the scripts could be run without any issues.

I hope this helps somebody...