Python 更新破坏了 apt-listchanges,彻底破坏了 apt 和 dpkg

Python 更新破坏了 apt-listchanges,彻底破坏了 apt 和 dpkg
  • 操作系统:Debian 11
  • OG Python 版本:3.9

我将 python 更新到 3.10 并执行了此操作update-alternatives,但在运行时pip出现错误:

E: Sub-process /usr/bin/apt-listchanges --apt || test $? -ne 10 returned an error code (1)
E: Failure running script /usr/bin/apt-listchanges --apt || test $? -ne 10

经过一番搜索,我找到了一些解决方案:

我随机做了:

  • update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1
  • update-alternatives --install /usr/local/bin/python python /usr/bin/python3.10 1
  • update-alternatives --install /usr/bin/pip pip /usr/bin/pip3.10 1
  • update-alternatives --install /usr/local/bin/pip pip /usr/bin/python3.10 1

这些都没有修复,所以我决定python3.10通过删除符号链接并为 python3.9 创建符号链接来删除,但这没有用。现在,我开始收到 dpkg 错误:

dpkg: error processing package python3 (--configure):
 subprocess installed post-installation script returned error exit status 1

我不再有该文件/etc/apt/apt.conf.d/20listchanges。然后我尝试了以下方法:

sudo apt install -f
sudo dpkg --configure -a
sudo apt update && sudo apt upgrade

sudo apt install --reinstall python3给出:

Preparing to unpack .../python3_3.9.2-3_amd64.deb ...
/var/lib/dpkg/info/python3.prerm: 5: py3clean: not found
dpkg: warning: old python3 package pre-removal script subprocess returned error exit status 127
dpkg: trying script from the new package instead ...
/var/lib/dpkg/tmp.ci/prerm: 5: py3clean: not found
dpkg: error processing archive /var/cache/apt/archives/python3_3.9.2-3_amd64.deb (--unpack):
 new python3 package pre-removal script subprocess returned error exit status 127
/var/lib/dpkg/info/python3.postinst: 47: py3compile: not found
dpkg: error while cleaning up:
 installed python3 package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
 /var/cache/apt/archives/python3_3.9.2-3_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我仍然拥有 Python 3.9 和 Python 3.10,apt update没有明显抛出错误,apt clean也没有返回任何内容upgrade,并且autoremove返回:

dpkg: error processing package python3 (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
Errors were encountered while processing:
 python3
E: Sub-process /usr/bin/dpkg returned an error code (1)

默认建议是删除有问题的包运行clean, autoremove & update,因为它是 python3,我不想删除它,因为有太多包和操作系统依赖它,我很害怕。

我非常感谢这个问题能够得到解决,而无需我重新安装操作系统。

感谢您的阅读

答案1

在 Stretch Raspbian 系统上安装 Python3.9.5 后,我在 Raspberry Pi 3 B+ 上遇到了完全相同的错误。不幸的是,我应该更新操作系统,但现在我遇到了这个问题。我真的希望有人能帮忙。这真是一个可怕而烦人的问题。

答案2

尝试关注

sudo apt install --reinstall python3{,-minimal,-apt}
sudo apt-get --reinstall install apt-listchanges

相关内容