E: 无法修正错误

虚拟机,bullseye+gnome,升级到最新之后,sudo apt install python3-sphinx提示错误,截图如下:

这个有啥办法?

我检查了bullseye分发的包python3-distutilspython3-lib2to3的依赖关系,结果如下:

Package: python3-distutils
Depends: python3:any (>= 3.9.1-0~), python3:any (<< 3.10)
Breaks: libpython3.6-stdlib (<< 3.6.4~rc1-2), libpython3.7-stdlib (<< 3.7.0~a3-3), python3.6-2to3 (<< 3.6.4-2), python3.7-2to3 (<< 3.7.0~a3-3)
Replaces: libpython3.6-stdlib (<< 3.6.4~rc1-2), libpython3.7-stdlib (<< 3.7.0~a3-3), python3.6-2to3 (<< 3.6.4-2), python3.7-2to3 (<< 3.7.0~a3-3)
Provides: python3.9-distutils

Package: python3-lib2to3
Depends: python3:any (>= 3.9.1-0~), python3:any (<< 3.10)
Breaks: libpython3.6-stdlib (<< 3.6.4~rc1-2), libpython3.7-stdlib (<< 3.7.0~a3-3), python3.6-2to3 (<< 3.6.4-2), python3.7-2to3 (<< 3.7.0~a3-3)
Replaces: libpython3.6-stdlib (<< 3.6.4~rc1-2), libpython3.7-stdlib (<< 3.7.0~a3-3), python3.6-2to3 (<< 3.6.4-2), python3.7-2to3 (<< 3.7.0~a3-3)
Provides: python3.9-lib2to3

对这些字段的解释参见
https://www.debian.org/doc/manuals/debian-reference/ch02.zh-cn.html#_package_dependencies
观察

结论是,bullseye分发中的python3包版本应该是3.9.2-2。在bullseye分发中涉及3.8.6-1版本的python3包显然不正常
因此,我认为你现在的问题似乎是apt的元数据错误。执行命令apt update && apt full-upgrade后再试试?
附录
Depends - 依赖
Pre-Depends - 预依赖
Recommends - 推荐
Suggests - 建议
Enhances - 增强
Breaks - 破损
Conflicts - 冲突
Replaces - 替代
Provides - 提供

我检查了buster分发中包python3-distutilspython3-lib2to3的依赖信息,结果如下:

Package: python3-distutils
Depends: python3 (>= 3.7.1-1~), python3 (<< 3.8), python3-lib2to3 (>= 3.6.4)
Breaks: libpython3.6-stdlib (<< 3.6.5~rc1-3), libpython3.7-stdlib (<< 3.7.0~b2-2)
Replaces: libpython3.6-stdlib (<< 3.6.4~rc1-2), libpython3.7-stdlib (<< 3.7.0~a3-2)
Provides: python3.7-distutils

Package: python3-lib2to3
Depends: python3 (>= 3.7.1-1~), python3 (<< 3.8)
Breaks: libpython3.6-stdlib (<< 3.6.4~rc1-2), libpython3.7-stdlib (<< 3.7.0~a3-3), python3.6-2to3 (<< 3.6.4-2), python3.7-2to3 (<< 3.7.0~a3-3)
Replaces: libpython3.6-stdlib (<< 3.6.4~rc1-2), libpython3.7-stdlib (<< 3.7.0~a3-3), python3.6-2to3 (<< 3.6.4-2), python3.7-2to3 (<< 3.7.0~a3-3)
Provides: python3.7-lib2to3

观察
https://packages.debian.org/python3
结论是,buster分发中python3的版本是3.7.3-1。
因此,我的结论是你的apt元数据出现了错误,现在你的apt元数据仍然保留了buster分发的部分元数据。
余下的问题是为何会存在python3的3.8.6-1版本。
https://tracker.debian.org/pkg/python3-defaults
信息显示python3包的3.8.6-1版本于2020/10/13进入unstable分发,于2020/11/09进入testing分发。但是,python3的3.9.0-4版本于2020/12/06进入testing分发,取代了3.8.6-1版本。我的推测是系统曾经经历过在2020/11/09至2020/12/06间进行了更新并将python3升级到了3.8.6-1版本,而届时包python3-distutilspython3-lib2to3尚未更新。此后系统没有进行更新,因此现在试图安装包python3-distutilspython3-lib2to3,在apt试图自动解决依赖关系时遇到了失败。
建议:执行命令apt update && apt full-upgrade后再次尝试安装包。
说明
你遇到的情况属于"testing being broken"的典型例子,从Debian FAQ解释的包进入testing的流程:

The bug fixes and improvements introduced in the unstable distribution trickle down to testing after a certain number of days. Let’s say this threshold is 5 days. The packages in unstable go into testing only when there are no RC-bugs reported against them. If there is a RC-bug filed against a package in unstable, it will not go into testing after the 5 days.

因此,在这个例子中,可能发生的故事是包python3在unstable分发的包迁移到了testing分发而包python3-distutilspython3-lib2to3在unstable分发的包由于某种原因尚未迁移到testing分发,于是依赖关系暂时被破坏了。然而由于更新仅涉及包python3,这一问题被掩盖了,并且由于迄今为止都未曾再次更新apt元数据而导致现在以安装包时无法解决的依赖关系表现出来。

犯了个低级错误,sources.list我顺手使用了buster,而不是testing~

……:joy:
其实关于dpkg存在手动修复依赖关系的说明,但是这里很明显不是这个问题……