python - 无法 apt-get 安装包 E : Sub-process/usr/bin/dpkg returned an error code (1)

标签 python linux python-3.x mercurial debian

每当我尝试使用 apt-get install 安装软件包时,我都会遇到以下错误:

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)

我目前在我的机器上使用 Python 3.4.2。

最佳答案

您是否将默认的 Python 从 Python2 更改为 Python3?目前,Debian 带有一个 default Python2 installation .用 Python 编写的系统脚本,例如 /usr/sbin/update-python-modules 期望 python 运行 Python2 版本。将默认 python 更改为 Python3 将导致各种脚本中断。如果您确实将 Python3 设为默认值,解决当前问题的方法是恢复并再次将 Python2 设为默认值。


在Python2中print是一个语句,所以print x是有效的。

在 Python3 中,print 是一个函数,因此调用该函数需要将参数括在括号内。所以print x必须改成print(x)print x 引发了一个SyntaxError:

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

不要更改系统的默认 python,而是使用 pyenv or virtualenv在多个 Python 版本之间进行管理/切换。

关于python - 无法 apt-get 安装包 E : Sub-process/usr/bin/dpkg returned an error code (1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36368426/

相关文章:

python - 如果列值的顺序发生变化,则拆分数据框 pandas

python - mmap:在不知道其大小的情况下无法附加到现有区域(Windows)

c - GNU/Linux 线程实现

python - SSL ConnectionResetError 从哪里来?

python - 我下载了漏洞利用脚本,当尝试运行它时,它给了我一个错误

python - 如何获取方法参数名称?

python - 重试python中脚本/程序停止的地方,记住变量值

linux - 在48GB内存的64位机器上,Linux内核占用的虚拟内存大小是多少?

linux - QT 添加到 Netbeans 中的 qmake 文件

python - 我同时安装了 python 2.7 和 3.5,但是 python 3.5 不能正常工作