Sudo apt upgrade 不起作用!!未满足依赖项 Python 3

Sudo apt upgrade 不起作用!!未满足依赖项 Python 3

我最近安装了 Python3.8,一切运行正常,可以在终端中成功使用各种版本的 Python。几天后,我调用了sudo apt update,一切正常,但当我这样做时,sudo apt upgrade我收到了下面的错误消息。我尝试执行sudo apt --fix-broken install,子进程返回了一个错误代码。
当我尝试sudo apt upgrade
输出

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:
dh-python : Depends: python3-distutils but it is not installed
python3-dev : Depends: python3-distutils (>= 3.6.7-1~) but it is not installed
python3-pip : Depends: python3-distutils but it is not installed
python3-setuptools : Depends: python3-distutils but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

当我尝试sudo apt --fix-broken install
输出

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  libllvm7 libllvm8 libllvm8:i386 libpython3.7-minimal libpython3.7-stdlib
  python3.7-minimal
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  python3-distutils python3-lib2to3
The following NEW packages will be installed:
  python3-distutils python3-lib2to3
0 upgraded, 2 newly installed, 0 to remove and 122 not upgraded.
10 not fully installed or removed.
Need to get 0 B/222 kB of archives.
After this operation, 3,143 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 201984 files and directories currently installed.)
Preparing to unpack .../python3-lib2to3_3.6.9-1~18.04_all.deb ...
Unpacking python3-lib2to3 (3.6.9-1~18.04) ...
dpkg: error processing archive /var/cache/apt/archives/python3-lib2to3_3.6.9-1~18.04_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3.8/lib2to3/Grammar.txt', which is also in package python3.8-lib2to3 3.8.0-1+bionic2
Preparing to unpack .../python3-distutils_3.6.9-1~18.04_all.deb ...
Unpacking python3-distutils (3.6.9-1~18.04) ...
dpkg: error processing archive /var/cache/apt/archives/python3-distutils_3.6.9-1~18.04_all.deb (--unpack):
trying to overwrite '/usr/lib/python3.8/distutils/README', which is also in package python3.8-distutils 3.8.0-1+bionic2
Errors were encountered while processing:
 /var/cache/apt/archives/python3-lib2to3_3.6.9-1~18.04_all.deb
 /var/cache/apt/archives/python3-distutils_3.6.9-1~18.04_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我也尝试过这样做sudo apt --fix-broken install python3-distutils
输出

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:
 python3-distutils : Depends: python3-lib2to3 (>= 3.6.4) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).```

我也试过sudo apt --fix-broken install python3-lib2to3
输出

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:
 dh-python : Depends: python3-distutils but it is not going to be installed
 python3-dev : Depends: python3-distutils (>= 3.6.7-1~) but it is not going to be installed
 python3-pip : Depends: python3-distutils but it is not going to be installed
 python3-setuptools : Depends: python3-distutils but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

感谢您提供的任何帮助!

更新

当我尝试做sudo apt install aptitude

输出

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:
 aptitude : Depends: aptitude-common (= 0.8.10-6ubuntu1) but it is not going to be installed
            Depends: libcwidget3v5 but it is not going to be installed
 dh-python : Depends: python3-distutils but it is not going to be installed
 python3-dev : Depends: python3-distutils (>= 3.6.7-1~) but it is not going to be installed
 python3-pip : Depends: python3-distutils but it is not going to be installed
 python3-setuptools : Depends: python3-distutils but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

答案1

请尝试使用以下命令:

sudo apt dist-upgrade 

因为 dist-upgrade 还处理新的包依赖关系。

此处解释如下: 为什么使用 apt-get upgrade 而不是 apt-get dist-upgrade?

答案2

最简单的方法:

sudo apt-get install aptitude-common libcwidget3v5
sudo aptitude upgrade

或者

sudo apt-get install python3-distutils

答案3

如果您想升级但无法升级,有很多方法可以解决这个问题:

方法 1

步骤 1:打开软件与更新

第 2 步:更改Download from主服务器

步骤 3 :打开终端(ctlr + alt + tsudo apt-get update,然后sudo apt-get upgrade

方法 2 删除 PPA

步骤 1:打开软件与更新

步骤 2:转到“其他软件”选项卡,从列表中选择所需的 PPA。然后点击消除将其删除。

或者

您可以使用终端将其删除:sudo apt-add-repository -r PPA_Name/ppa

方法三:

读这个

也尝试使用这个命令,希望它有帮助:sudo apt clean,,sudo apt autocleansudo apt autoremove

希望这对你有帮助!

相关内容