升级 python3.10 时子进程 /usr/bin/dpkg 返回错误代码 (1)

Ude*_*esh 54 upgrade apt dpkg dependencies 20.04

apt upgrade:

$ sudo apt-get full-upgrade -y

Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 libpython3.10 : Depends: libpython3.10-stdlib (= 3.10.4-1+focal2) but 3.10.4-1+focal1 is installed
 libpython3.10-dev : Depends: libpython3.10-stdlib (= 3.10.4-1+focal2) but 3.10.4-1+focal1 is installed
 python3.10 : Depends: libpython3.10-stdlib (= 3.10.4-1+focal2) but 3.10.4-1+focal1 is installed
 python3.10-minimal : Depends: libpython3.10-minimal (= 3.10.4-1+focal2) but 3.10.4-1+focal1 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
Run Code Online (Sandbox Code Playgroud)

apt --fix-broken install:

$ sudo apt --fix-broken install

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  libpython3.10-minimal libpython3.10-stdlib
The following packages will be upgraded:
  libpython3.10-minimal libpython3.10-stdlib
2 upgraded, 0 newly installed, 0 to remove and 10 not upgraded.
9 not fully installed or removed.
Need to get 0 B/2,566 kB of archives.
After this operation, 68.6 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 279178 files and directories currently installed.)
Preparing to unpack .../libpython3.10-stdlib_3.10.4-1+focal2_amd64.deb ...
Unpacking libpython3.10-stdlib:amd64 (3.10.4-1+focal2) over (3.10.4-1+focal1) ...
dpkg: error processing archive /var/cache/apt/archives/libpython3.10-stdlib_3.10.4-1+focal2_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/python3.10/_sysconfigdata__linux_x86_64-linux-gnu.py', which is also in package libpython3.10-minimal:amd64 3.10.4-1+fo
cal1
Preparing to unpack .../libpython3.10-minimal_3.10.4-1+focal2_amd64.deb ...
Unpacking libpython3.10-minimal:amd64 (3.10.4-1+focal2) over (3.10.4-1+focal1) ...
dpkg: error processing archive /var/cache/apt/archives/libpython3.10-minimal_3.10.4-1+focal2_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/python3.10/typing.py', which is also in package libpython3.10-stdlib:amd64 3.10.4-1+focal1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/libpython3.10-stdlib_3.10.4-1+focal2_amd64.deb
 /var/cache/apt/archives/libpython3.10-minimal_3.10.4-1+focal2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Run Code Online (Sandbox Code Playgroud)

尝试删除已安装的python3.10软件包,但结果出现错误 Unmet dependencies

此错误消息意味着什么?有解决方法吗?

Ric*_*ice 103

尝试删除有问题的软件包,即 libpython3.10-minimal libpython3.10-stdlib。

sudo apt remove libpython3.10-minimal libpython3.10-stdlib
Run Code Online (Sandbox Code Playgroud)

如果这说要运行 --fix-broken 然后手动删除它,就像这样

ls -l /var/lib/dpkg/info | grep -i libpython3.10-minimal
Run Code Online (Sandbox Code Playgroud)

这显示了包含libpython3.10-minimal. 现在将其移动到另一个目录中

sudo mv /var/lib/dpkg/info/libpython3.10-minimal:amd64.* /tmp
Run Code Online (Sandbox Code Playgroud)

然后做

sudo apt --fix-broken install
Run Code Online (Sandbox Code Playgroud)

它会说 libpython3.10-minimal 未找到,因此它将重新安装它。

  • @UdeshRanjan 一个文件从 -stdlib 移动到 -minimal,另一个文件从 -minimal 移动到 -stdlib,因此两个文件都不能在不覆盖另一个文件的情况下先执行。删除它们都清除了这个条件(尽管我会使用`dpkg --remove --force-all`而不是伪造/var/lib/dpkg/info) (10认同)
  • 我遵循@hobbs的建议,在 Ubuntu 20.04 LTS 中非常轻松地解决了问题:“sudo dpkg --remove --force-all libpython3.10-minimal libpython3.10-stdlib”,然后是“sudo apt install libpython3.10-minimal libpython3” .10-stdlib`。 (3认同)

Don*_*kby 15

正如Ricehobbs所说,问题在于文件从一个包移动到另一个包,并且它们现在在更新过程中互相踩踏。我听从了他们的建议强制升级,但不得不稍微调整一下。这就是我最终所做的:

sudo dpkg --force-all --remove libpython3.10-stdlib libpython3.10-minimal
Run Code Online (Sandbox Code Playgroud)

这会强制卸载两个冲突的软件包,即使其他软件包依赖于它们。

sudo apt-get install libpython3.10-stdlib libpython3.10-minimal
Run Code Online (Sandbox Code Playgroud)

这会再次安装它们,而不会互相踩踏。sudo apt --fix-broken install此时可能也有效,但我没有尝试。