luishengjie
luishengjie

Reputation: 187

Unable to apt-get install packages E: Sub-process /usr/bin/dpkg returned an error code (1)

Whenever i try to install a package with apt-get install I would encounter the following error:

After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python-support (1.0.15) ...
  File "/usr/sbin/update-python-modules", line 52
    print x
          ^
SyntaxError: Missing parentheses in call to 'print'
dpkg: error processing package python-support (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up mercurial-common (3.1.2-2+deb8u1) ...
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 35, 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 processing package mercurial-common (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mercurial:
 mercurial depends on mercurial-common (= 3.1.2-2+deb8u1); however:
  Package mercurial-common is not configured yet.

dpkg: error processing package mercurial (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 python-support
 mercurial-common
 mercurial
E: Sub-process /usr/bin/dpkg returned an error code (1)

I am currently using Python 3.4.2 on my machine.

Upvotes: 1

Views: 2458

Answers (1)

unutbu
unutbu

Reputation: 880957

Did you change your default python from Python2 to Python3? Currently, Debian comes with a default Python2 installation. System scripts written in Python such as /usr/sbin/update-python-modules expect python to run a version of Python2. Changing the default python to Python3 will cause all sorts of scripts to break. If you did make Python3 the default, the way to fix your current problem is to revert and make Python2 the default again.


In Python2 print is a statement, so print x is valid.

In Python3 print is a function, so calling the function requires wrapping the arguments inside parentheses. So print x must be changed to print(x). print x raises a SyntaxError:

  File "/usr/sbin/update-python-modules", line 52
    print x
          ^
SyntaxError: Missing parentheses in call to 'print'

Instead of changing the system's default python, use pyenv or virtualenv to manage / switch between multiple versions of Python.

Upvotes: 5

Related Questions