0
votes

I am trying to install rails on ubuntu 17.04 but it was giving an error. Then I tried to run other installations but the error was same.
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
When I tried to execute sudo dpkg --configure -a , I faced following output:

Setting up python-crypto (2.6.1-7) ...
Traceback (most recent call last):
File "/usr/bin/pycompile", line 35, in  from debpython.version import SUPPORTED, debsorted, vrepr, \
File "/usr/share/python/debpython/version.py", line 24, in  from ConfigParser import SafeConfigParser ImportError: No module named 'ConfigParser' dpkg: error processing package python-crypto (--configure):
     subprocess installed post-installation script returned error exit status 1

Setting up python-sqlparse (0.2.2-1) ...
Traceback (most recent call last):
File "/usr/bin/pycompile", line 35, in  from debpython.version import SUPPORTED, debsorted, vrepr, \
File "/usr/share/python/debpython/version.py", line 24, in  from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error processing package python-sqlparse (--configure): subprocess installed post-installation script returned error exit status 1
Setting up python-wheel (0.29.0-2) ...
Traceback (most recent call last):
    File "/usr/bin/pycompile", line 35, in  from debpython.version import SUPPORTED, debsorted, vrepr, \
    File "/usr/share/python/debpython/version.py", line 24, in  from ConfigParser import SafeConfigParser
    ImportError: No module named 'ConfigParser'
    dpkg: error processing package python-wheel (--configure):
        subprocess installed post-installation script returned error exit status 1

Setting up python-tz (2014.10~dfsg1-0ubuntu2) ...
    Traceback (most recent call last):
      File "/usr/bin/pycompile", line 35, in  from debpython.version import SUPPORTED, debsorted, vrepr, \
      File "/usr/share/python/debpython/version.py", line 24, in  from ConfigParser import SafeConfigParser
    ImportError: No module named 'ConfigParser'
    dpkg: error processing package python-tz (--configure):
     subprocess installed post-installation script returned error exit status 1
    dpkg: dependency problems prevent configuration of python-keyrings.alt:
     python-keyrings.alt depends on python-crypto; however:
      Package python-crypto is not configured yet.

    dpkg: error processing package python-keyrings.alt (--configure):
     dependency problems - leaving unconfigured
    Setting up python-gi (3.22.0-2) ...
    Traceback (most recent call last):
      File "/usr/bin/pycompile", line 35, in 
        from debpython.version import SUPPORTED, debsorted, vrepr, \
      File "/usr/share/python/debpython/version.py", line 24, in 
        from ConfigParser import SafeConfigParser
    ImportError: No module named 'ConfigParser'
    dpkg: error processing package python-gi (--configure):
     subprocess installed post-installation script returned error exit status 1
    Setting up python-mysqldb (1.3.7-1.1) ...
    Traceback (most recent call last):
      File "/usr/bin/pycompile", line 35, in 
        from debpython.version import SUPPORTED, debsorted, vrepr, \
      File "/usr/share/python/debpython/version.py", line 24, in 
        from ConfigParser import SafeConfigParser
    ImportError: No module named 'ConfigParser'
    dpkg: error processing package python-mysqldb (--configure):
     subprocess installed post-installation script returned error exit status 1
    dpkg: error processing package apport (--configure):
     package is in a very bad inconsistent state; you should
     reinstall it before attempting configuration
    Setting up python-django (1.8.7-1ubuntu11) ...
    Traceback (most recent call last):
      File "/usr/bin/pycompile", line 35, in 
        from debpython.version import SUPPORTED, debsorted, vrepr, \
      File "/usr/share/python/debpython/version.py", line 24, in 
        from ConfigParser import SafeConfigParser
    ImportError: No module named 'ConfigParser'
    dpkg: error processing package python-django (--configure):
     subprocess installed post-installation script returned error exit status 1
    Setting up python-dbus (1.2.4-1) ...
    Remove stale byte-compiled files...
    Traceback (most recent call last):
      File "/usr/bin/pycompile", line 35, in 
        from debpython.version import SUPPORTED, debsorted, vrepr, \
      File "/usr/share/python/debpython/version.py", line 24, in 
        from ConfigParser import SafeConfigParser
    ImportError: No module named 'ConfigParser'
    dpkg: error processing package python-dbus (--configure):
     subprocess installed post-installation script returned error exit status 1
    Setting up python-pip (9.0.1-2) ...
    Traceback (most recent call last):
      File "/usr/bin/pycompile", line 35, in 
        from debpython.version import SUPPORTED, debsorted, vrepr, \
      File "/usr/share/python/debpython/version.py", line 24, in 
        from ConfigParser import SafeConfigParser
    ImportError: No module named 'ConfigParser'
    dpkg: error processing package python-pip (--configure):
     subprocess installed post-installation script returned error exit status 1
    Setting up python-xdg (0.25-4) ...
    Traceback (most recent call last):
      File "/usr/bin/pycompile", line 35, in 
        from debpython.version import SUPPORTED, debsorted, vrepr, \
      File "/usr/share/python/debpython/version.py", line 24, in 
        from ConfigParser import SafeConfigParser
    ImportError: No module named 'ConfigParser'
    dpkg: error processing package python-xdg (--configure):
     subprocess installed post-installation script returned error exit status 1
    dpkg: dependency problems prevent configuration of python-secretstorage:
     python-secretstorage depends on python-dbus; however:
      Package python-dbus is not configured yet.

    dpkg: error processing package python-secretstorage (--configure):
     dependency problems - leaving unconfigured
    dpkg: dependency problems prevent configuration of python-keyring:
     python-keyring depends on python-dbus; however:
      Package python-dbus is not configured yet.
     python-keyring depends on python-secretstorage; however:
      Package python-secretstorage is not configured yet.

    dpkg: error processing package python-keyring (--configure):
     dependency problems - leaving unconfigured
    Errors were encountered while processing:
     python-crypto
     python-sqlparse
     python-wheel
     python-tz
     python-keyrings.alt
     python-gi
     python-mysqldb
     apport
     python-django
     python-dbus
     python-pip
     python-xdg
     python-secretstorage
     python-keyring

Tried following solution,


    [cd /var/lib/dpkg/updates
    sudo rm *
    sudo apt-get update][1]

from here but didn't help me. I am using python3.5 as my default python. I have changed it using alias.

4

4 Answers

4
votes

make sure everything is deleted under: /var/lib/dpkg/updates

then try the command again:

sudo dpkg --configure -a 
0
votes

Try changing the python version, for me it worked, you can use update-alternatives --config to switch between python versions without using an alias.

0
votes

This is due to the byte compiler /usr/bin/pycompile is broken after you change the default python version from python2 to python3.

To fix this, you can simply replace it to /usr/bin/py3compile as following commands:

sudo mv /usr/bin/pycompile /usr/bin/py2compile
sudo ln -s /usr/bin/py3compile /usr/bin/pycompile

Everything works fine by my side with this.

-1
votes

I had this problem before it was because something went wrong during installation. Try this command to fix broken packages:

sudo apt-get install -f

And then try to run sudo dpkg --configure -a again

reference : https://askubuntu.com/a/163339/183864