ubuntu jammy apt 升级问题。python3-distutils 和 python3-lib2to3 无法升级

ubuntu jammy apt 升级问题。python3-distutils 和 python3-lib2to3 无法升级

我打字时出现错误;

sudo apt upgrade

错误是;

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 python3-dev : Depends: python3-distutils (>= 3.10.6-1~) but 3.10.4-0ubuntu1 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

如果我尝试打字;

sudo apt --fix-broken install

问题没有解决,我遇到了同样的错误。

“apt policy python3-distutils”报告如下;

python3-distutils:
  Installed: 3.10.4-0ubuntu1
  Candidate: 3.10.6-1~22.04
  Version table:
     3.10.6-1~22.04 500
        500 http://tr.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
        500 http://tr.archive.ubuntu.com/ubuntu jammy-updates/main i386 Packages
 *** 3.10.4-0ubuntu1 500
        500 http://tr.archive.ubuntu.com/ubuntu jammy/main amd64 Packages
        500 http://tr.archive.ubuntu.com/ubuntu jammy/main i386 Packages
        100 /var/lib/dpkg/status

“sudo apt --fix-broken install” 也出现如下错误;

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  python3-distutils python3-lib2to3
The following packages will be upgraded:
  python3-distutils python3-lib2to3
2 upgraded, 0 newly installed, 0 to remove and 25 not upgraded.
9 not fully installed or removed.
Need to get 0 B/216 kB of archives.
After this operation, 105 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 319749 files and directories currently installed.)
Preparing to unpack .../python3-distutils_3.10.6-1~22.04_all.deb ...
Unpacking python3-distutils (3.10.6-1~22.04) over (3.10.4-0ubuntu1) ...
dpkg: error processing archive /var/cache/apt/archives/python3-distutils_3.10.6-
1~22.04_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3.11/distutils/README', which is also in pa
ckage python3.11-distutils 3.11.0~rc2-1+jammy1
Preparing to unpack .../python3-lib2to3_3.10.6-1~22.04_all.deb ...
Unpacking python3-lib2to3 (3.10.6-1~22.04) over (3.10.4-0ubuntu1) ...
dpkg: error processing archive /var/cache/apt/archives/python3-lib2to3_3.10.6-1~
22.04_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3.11/lib2to3/Grammar.txt', which is also in
 package python3.11-lib2to3 3.11.0~rc2-1+jammy1
Errors were encountered while processing:
 /var/cache/apt/archives/python3-distutils_3.10.6-1~22.04_all.deb
 /var/cache/apt/archives/python3-lib2to3_3.10.6-1~22.04_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

我的系统上也出现了同样的错误。原来是 python3.11 和 python3.10 之间存在冲突。运行这些命令帮我解决了这个问题。

sudo dpkg -r python3.11-distutils
sudo dpkg -r python3.11-lib2to3
sudo apt --fix-broken install

我通过尝试手动安装有问题的软件包并获取更详细的错误消息找到了它。

当我尝试安装 python3-distutils 时,apt 说无法安装 pyhton3-lib2to3。因此我从这里下载了 deb。

之后我收到一条很长的错误信息,最后是这样的:

dpkg: error processing archive /var/cache/apt/archives/python3-lib2to3_3.10.6-
1~22.04_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3.11/lib2to3/Grammar.txt', which is also 
in package python3.11-lib2to3 3.11.0~rc2-1+jammy1
Errors were encountered while processing:
 /var/cache/apt/archives/python3-distutils_3.10.6-1~22.04_all.deb
 /var/cache/apt/archives/python3-lib2to3_3.10.6-1~22.04_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

这就是我删除 python3.11-lib2to3 的线索。希望上述三个命令可以解决您的问题,或者解决类似的问题。

相关内容