我上周遇到了这个问题(在旧安装和全新安装上),当尝试安装新软件包时,我收到依赖性错误,因为需要安装比要求更新的版本。
以下是发生这种情况时错误消息的一个示例(但不限于这种特定情况):
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created or
been moved out of Incoming. The following information may help to
resolve the situation:
The following packages have unmet dependencies:
g++-11 : Depends: gcc-11-base (= 11.2.0-19ubuntu1) but 11.3.0-1ubuntu1~22.04 is to be installed
Depends: gcc-11 (= 11.2.0-19ubuntu1) but 11.3.0-1ubuntu1~22.04 is to be installed
Depends: libstdc++-11-dev (= 11.2.0-19ubuntu1) but it is not going to be installed
E: Unable to correct problems, you have held
broken packages.
感觉我通过更新获得了一些更新,超出了依赖关系图认为应该的范围,但我真的不确定我是如何遇到这个问题的。
编辑以添加:检查 apt-cach 策略可能会提供线索,但我不知道如何根据这些信息采取行动:
$ apt-cache policy gcc-11 gcc-11-base python3
gcc-11:
Installed: 11.3.0-1ubuntu1~22.04
Candidate: 11.3.0-1ubuntu1~22.04
Version table:
*** 11.3.0-1ubuntu1~22.04 100
100 /var/lib/dpkg/status
11.2.0-19ubuntu1 500
500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
gcc-11-base:
Installed: 11.3.0-1ubuntu1~22.04
Candidate: 11.3.0-1ubuntu1~22.04
Version table:
*** 11.3.0-1ubuntu1~22.04 100
100 /var/lib/dpkg/status
11.2.0-19ubuntu1 500
500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
python3:
Installed: 3.10.6-1~22.04
Candidate: 3.10.6-1~22.04
Version table:
*** 3.10.6-1~22.04 500
500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
100 /var/lib/dpkg/status
3.10.4-0ubuntu2 500
500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages