E:dpkg 被中断,必须手动运行'sudo dpkg --configure -a'才能更正



我正在尝试在 ubuntu 17.04 上安装导轨,但它给出了一个错误。然后我尝试运行其他安装,但错误是相同的。
E:dpkg 被中断,必须手动运行 'sudo dpkg --配置 -a' 来纠正问题。
当我尝试执行sudo dpkg --配置 -a时, 我面临以下输出:

设置 python-crypto (2.6.1-7) ... 回溯(最近一次调用): 文件 "/usr/bin/pycompile", 第 35 行, in from debpython.version import SUPPORTED, debsorted, vrepr, \ 文件 "/usr/share/python/debpython/version.py",第 24 行,来自 ConfigParser import SafeConfigParser ImportError: 没有名为 'ConfigParser' 的模块 dpkg: 错误处理包 python-crypto (--configure):  子进程已安装 安装后脚本返回错误退出状态 1 设置 python-sqlparse (0.2.2-1) ...回溯(最近一次调用): 文件 "/usr/bin/pycompile", 第 35 行, in from debpython.version import SUPPORTED, debsorted, vrepr, \ 文件 "/usr/share/python/debpython/version.py",第 24 行,来自 ConfigParser 导入 SafeConfigParser 导入错误:没有名为"配置解析器"的模块 dpkg:错误处理包 python-sqlparse (--configure):子进程已安装 安装后脚本返回错误退出状态 1 设置蟒蛇轮 (0.29.0-2) ... 回溯(最近一次调用): 文件 "/usr/bin/pycompile", 第 35 行, in from debpython.version import SUPPORTED, debsorted, vrepr, \ 文件 "/usr/share/python/debpython/version.py",第 24 行,来自 ConfigParser 导入 SafeConfigParser 导入错误:没有名为"配置解析器"的模块 dpkg:错误处理包 python-wheel (--configure): 子进程已安装 安装后脚本返回错误退出状态 1 设置 python-tz (2014.10~dfsg1-0ubuntu2) ... 回溯(最近一次调用):文件 "/usr/bin/pycompile", 第 35 行, in from debpython.version import SUPPORTED, debsorted, vrepr, \ 文件 "/usr/share/python/debpython/version.py",第 24 行,来自 ConfigParser 导入 SafeConfigParser 导入错误:没有名为"配置解析器"的模块 dpkg:错误处理包 python-tz (--configure):  子进程已安装 安装后脚本返回错误退出状态 1 dpkg:依赖问题阻止了 python-keyrings.alt 的配置:  python-keyrings.alt 依赖于 python-crypto;然而: 尚未配置包 python-crypto。 dpkg:错误处理包 python-keyrings.alt (--configure):  依赖项问题 - 未配置 设置 python-gi (3.22.0-2) ... 回溯(最近一次调用): 文件 "/usr/bin/pycompile",第 35 行,在 from debpython.version import SUPPORTED, debsorted, vrepr, \ 文件 "/usr/share/python/debpython/version.py",第 24 行,在 从配置解析器导入安全配置解析器 导入错误:没有名为"配置解析器"的模块dpkg:处理包 python-gi 的错误 (--configure):  子进程已安装 安装后脚本返回错误退出状态 1 设置 python-mysqldb (1.3.7-1.1) ... 回溯(最近一次调用): 文件 "/usr/bin/pycompile",第 35 行,在 from debpython.version import SUPPORTED, debsorted, vrepr, \ 文件 "/usr/share/python/debpython/version.py",第 24 行,在 从配置解析器导入安全配置解析器 导入错误:没有名为"配置解析器"的模块 dpkg: 错误处理包 python-mysqldb (--configure):  子进程已安装 安装后脚本返回错误退出状态 1 dpkg:处理软件包应用程序时出错(--配置):  包处于非常糟糕的不一致状态;你应该  在尝试配置之前重新安装它 设置 python-django (1.8.7-1ubuntu11) ... 回溯(最近一次调用): 文件 "/usr/bin/pycompile",第 35 行,在 from debpython.version import SUPPORTED, debsorted, vrepr, \文件 "/usr/share/python/debpython/version.py",第 24 行,在 从配置解析器导入安全配置解析器 导入错误:没有名为"配置解析器"的模块 dpkg:错误处理包 python-django (--configure):  子进程已安装 安装后脚本返回错误退出状态 1 设置 python-dbus (1.2.4-1) ... 删除过时的字节编译文件... 回溯(最近一次调用): 文件 "/usr/bin/pycompile",第 35 行,在 from debpython.version import SUPPORTED, debsorted, vrepr, \ 文件 "/usr/share/python/debpython/version.py",第 24 行,在 从配置解析器导入安全配置解析器 导入错误:没有名为"配置解析器"的模块 dpkg:处理包 python-dbus 时出错 (--configure):  子进程已安装 安装后脚本返回错误退出状态 1 设置 python-pip (9.0.1-2) ... 回溯(最近一次调用): 文件 "/usr/bin/pycompile",第 35 行,在 from debpython.version import SUPPORTED, debsorted, vrepr, \文件 "/usr/share/python/debpython/version.py",第 24 行,在 从配置解析器导入安全配置解析器 导入错误:没有名为"配置解析器"的模块 dpkg:错误处理包 python-pip (--configure):  子进程已安装 安装后脚本返回错误退出状态 1 设置 python-xdg (0.25-4) ... 回溯(最近一次调用): 文件 "/usr/bin/pycompile",第 35 行,在 from debpython.version import SUPPORTED, debsorted, vrepr, \ 文件 "/usr/share/python/debpython/version.py",第 24 行,在 从配置解析器导入安全配置解析器 导入错误:没有名为"配置解析器"的模块 dpkg:错误处理包 python-xdg (--configure):  子进程已安装 安装后脚本返回错误退出状态 1 dpkg:依赖问题阻止了 python-secretstorage 的配置:  python-secretstorage 依赖于 python-dbus;然而: 尚未配置软件包 python-dbus。 dpkg:处理包 python-secretstorage 的错误 (--configure):依赖项问题 - 未配置 dpkg:依赖问题阻止了 python-keyring 的配置:  python-keyring 依赖于 python-dbus;然而: 尚未配置软件包 python-dbus。  python-keyring 依赖于 python-secretstorage;然而: 尚未配置包 python-secretstorage。 dpkg:错误处理包 python-keyring (--configure):  依赖项问题 - 未配置 处理时遇到错误:  蟒蛇加密  python-sqlparse  蟒蛇轮  蟒蛇-茨  python-keyrings.alt  蟒蛇-GI  python-mysqldb  适用  python-django  python-dbus  python-pip  python-xdg  python-secretstorage  蟒蛇密钥环 尝试以下解决方案, [cd/var/lib/dpkg/updates 须藤 RM * sudo apt-get update][1]

从这里 但没有帮助我。 我正在使用python3.5作为我的默认python。我已经使用别名更改了它。

确保在以下位置删除所有内容:/var/lib/dpkg/updates

然后重试该命令:

sudo dpkg --configure -a 

尝试更改 python 版本,对我来说它奏效了,您可以使用update-alternatives --config在 python 版本之间切换而无需使用别名。

这是由于将默认 python 版本从 python2 更改为 python3 后字节编译器/usr/bin/pycompile被破坏。

要解决此问题,您只需将其替换为以下命令/usr/bin/py3compile

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

在我身边一切正常。

我之前遇到过这个问题是因为在安装过程中出了点问题。尝试以下命令来修复损坏的软件包:

sudo apt-get install -f

然后尝试再次运行sudo dpkg --configure -a

参考 : https://askubuntu.com/a/163339/183864

最新更新