linux_ubuntu_apt install安装某些软件包出现的大量的依赖包版本不满足条件的问题@较全攻略(以ssh服务的安装为例)/软件包安装状态检查

本文探讨了在Ubuntu中遇到大量依赖包版本不匹配问题的实例,如SSH服务安装失败和GNOME控制中心安装受限。主要问题源于更换源后包版本不一致。解决方案包括切换回原始源、清理并重新安装,以及利用aptitude工具处理依赖。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ubuntu_apt install安装某些软件包出现的大量的依赖包版本不满足条件的问题(以ssh服务的安装为例)/软件包安装状态检查

问题案例

ssh 案例

#( 08/20/21@ 6:13AM )( cxxu@ubuntu ):~
   sudo apt install openssh-server 
[sudo] password for cxxu: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
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:
 libbsd0:i386 : Depends: libc6:i386 (>= 2.25) but it is not installable
 libcbor0.6:i386 : Depends: libc6:i386 (>= 2.4) but it is not installable
 libcom-err2:i386 : Depends: libc6:i386 (>= 2.28) but it is not installable
 libedit2:i386 : Depends: libc6:i386 (>= 2.28) but it is not installable
 libfido2-1:i386 : Depends: libc6:i386 (>= 2.25) but it is not installable
 libgssapi-krb5-2:i386 : Depends: libc6:i386 (>= 2.27) but it is not installable
 libk5crypto3:i386 : Depends: libc6:i386 (>= 2.28) but it is not installable
 libkeyutils1:i386 : Depends: libc6:i386 (>= 2.7) but it is not installable
 libkrb5-3:i386 : Depends: libc6:i386 (>= 2.28) but it is not installable
 libkrb5support0:i386 : Depends: libc6:i386 (>= 2.8) but it is not installable
 libssl1.1:i386 : Depends: libc6:i386 (>= 2.28) but it is not installable
 libtinfo6:i386 : Depends: libc6:i386 (>= 2.16) but it is not installable
 libtirpc3 : Depends: libgssapi-krb5-2 (>= 1.17) but it is not installable
 libudev1:i386 : Depends: libc6:i386 (>= 2.30) but it is not installable
 openssh-client:i386 : Depends: dpkg:i386 (>= 1.7.0)
                       Depends: libc6:i386 (>= 2.28) but it is not installable
                       Depends: libselinux1:i386 (>= 1.32) but it is not installable
                       Recommends: xauth:i386
 openssh-server : Depends: dpkg (>= 1.9.0)
                  Depends: openssh-sftp-server
                  Depends: procps
                  Depends: libcom-err2 (>= 1.43.9) but it is not installable
                  Depends: libgssapi-krb5-2 (>= 1.17) but it is not installable
                  Depends: libkrb5-3 (>= 1.13~alpha1+dfsg) but it is not installable
                  Depends: libssl1.1 (>= 1.1.1) but it is not installable
                  Depends: zlib1g (>= 1:1.1.4) but it is not installable
                  Recommends: default-logind or
                              logind or
                              libpam-systemd but it is not going to be installed
                  Recommends: xauth
                  Recommends: ssh-import-id but it is not going to be installed
 perl-base : PreDepends: dpkg (>= 1.17.17)
 zlib1g:i386 : Depends: libc6:i386 (>= 2.4) but it is not installable
E: Unable to correct problems, you have held broken packages.

gnome-control-center案例(ubuntu20.04)

# cxxu @ u20 in ~/clash [4:22:19] C:100
$ sudo apt install gnome-control-center -f
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
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:
 gnome-control-center : Depends: libsmbclient (>= 2:4.0.3+dfsg1) but it is not going to be installed
                        Depends: colord (>= 0.1.30)
                        Depends: gnome-control-center-data (< 1:3.37) but 1:3.38.5-1ubuntu1 is to be installed
                        Depends: language-selector-gnome (>= 0.179~) but it is not going to be installed
                        Depends: system-config-printer (>= 1.4) but it is not going to be installed
                        Recommends: cups-pk-helper but it is not going to be installed
                        Recommends: gnome-online-accounts (>= 3.25.3) but it is not going to be installed
                        Recommends: network-manager-gnome (>= 0.9.8) but it is not going to be installed
                        Recommends: gnome-control-center-faces but it is not going to be installed
                        Recommends: rygel but it is not going to be installed or
                                    rygel-tracker but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

最可能的问题

我认为最可能的问题是更换了国内镜像源后,导致包的可用版本较为单一(要么过于新,要么过于旧,总之,依赖与被依赖找不到一个可以匹配上的成套的包)
显然,为了解决这个问题,一个粗暴的方法就是换回初始的国际源(虽然软件最为配套,但是下载速度有时候很慢(不过近几年感觉速度还是可以的),如果有代理的话,那么也可以加速)
或者更换别家的源(譬如从阿里源更换到清华源)
这里的第二个问题,在我将/etc/apt/source.list文件回复为初始版本(国外源),问题立刻得到解决

排查/解决

  • 一般是所要安装的软件包依赖其他软件,同时该软件已经安装,但是版本不满足当前所要安装软件的依赖,
  • 可以考虑将当前的被依赖包卸载,然后在执行当前包的安装

apt-cache 包检查

sudo apt-cache policy <packageName>

检查openssh-server/openssh-client的安装情况

  • 对比openssh-client 和openssh-server的版本

  • sudo apt-cache policy openssh-client openssh-server

    • 发现,目前时client以经安装,但是server还没有安装(意味着该主机无法被ssh连接)
#( 08/20/21@10:56PM )( cxxu@ubuntu ):~
   sudo apt-cache policy openssh-client openssh-server
openssh-client:
  Installed: 1:8.4p1-5ubuntu1
  Candidate: 1:8.4p1-5ubuntu1
  Version table:
 *** 1:8.4p1-5ubuntu1 100
        100 /var/lib/dpkg/status
     1:8.2p1-4ubuntu0.3 500
        500 http://mirrors.aliyun.com/ubuntu focal-updates/main amd64 Packages
     1:8.2p1-4ubuntu0.2 500
        500 http://mirrors.aliyun.com/ubuntu focal-security/main amd64 Packages
     1:8.2p1-4 500
        500 http://mirrors.aliyun.com/ubuntu focal/main amd64 Packages
        
        
openssh-server:
  Installed: (none)
  Candidate: 1:8.2p1-4ubuntu0.3
  Version table:
     1:8.2p1-4ubuntu0.3 500
        500 http://mirrors.aliyun.com/ubuntu focal-updates/main amd64 Packages
     1:8.2p1-4ubuntu0.2 500
        500 http://mirrors.aliyun.com/ubuntu focal-security/main amd64 Packages
     1:8.2p1-4 500
        500 http://mirrors.aliyun.com/ubuntu focal/main amd64 Packages

卸载已有的openssh-client:

sudo apt remove openssh-client

重新尝试

sudo apt install openssh-server

重新检查安装情况

#( 08/20/21@11:14PM )( cxxu@ubuntu ):~
   sudo apt-cache policy openssh-client openssh-server
openssh-client:
  Installed: 1:8.2p1-4ubuntu0.3
  Candidate: 1:8.2p1-4ubuntu0.3
  Version table:
 *** 1:8.2p1-4ubuntu0.3 500
        500 http://mirrors.aliyun.com/ubuntu focal-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     1:8.2p1-4ubuntu0.2 500
        500 http://mirrors.aliyun.com/ubuntu focal-security/main amd64 Packages
     1:8.2p1-4 500
        500 http://mirrors.aliyun.com/ubuntu focal/main amd64 Packages
openssh-server:
  Installed: 1:8.2p1-4ubuntu0.3
  Candidate: 1:8.2p1-4ubuntu0.3
  Version table:
 *** 1:8.2p1-4ubuntu0.3 500
        500 http://mirrors.aliyun.com/ubuntu focal-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     1:8.2p1-4ubuntu0.2 500
        500 http://mirrors.aliyun.com/ubuntu focal-security/main amd64 Packages
     1:8.2p1-4 500
        500 http://mirrors.aliyun.com/ubuntu focal/main amd64 Packages

从installled可知,版本匹配上了.

清理+重安装

以安装pip为例

问题说明

cxxu➜~» sudo apt install python3-pip                                            [18:12:49]
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
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:
 python3-setuptools : Depends: python3-pkg-resources (= 45.2.0-1) but 52.0.0-3 is to be installed
E: Unable to correct problems, you have held broken packages.

清理(purge)重装

可以尝试用通配符

  • sudo apt purge python3-pkg-resources
  • sudo apt install python3-pip
cxxu➜~» sudo apt purge python3-pkg-resources                                    [18:16:40]
[sudo] password for cxxu:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  apport-symptoms aptdaemon-data apturl-common avahi-utils cups-pk-helper gdb
  gir1.2-dbusmenu-glib-0.4 gir1.2-goa-1.0 gir1.2-javascriptcoregtk-4.0 gir1.2-notify-0.7
  gir1.2-packagekitglib-1.0 gir1.2-secret-1 gir1.2-snapd-1 gir1.2-vte-2.91
  gir1.2-webkit2-4.0 libappindicator3-1 libbabeltrace1 libboost-regex1.74.0 libc6-dbg
  libdebuginfod-common libdebuginfod1 libglu1-mesa libipt2 libsource-highlight-common
  libsource-highlight4v5 libwhoopsie-preferences0 libxss1 libxvmc1 python3-blinker
  python3-certifi python3-cffi-backend python3-cryptography python3-cups python3-dateutil
  python3-debconf python3-defer python3-httplib2 python3-idna python3-jeepney python3-jwt
...
Processing triggers for dbus (1.12.20-1ubuntu3) ...
Processing triggers for shared-mime-info (2.0-1) ...
Processing triggers for mailcap (3.68ubuntu1) ...
(Reading database ... 169465 files and directories currently installed.)
Purging configuration files for system-config-printer-common (1.5.15-0ubuntu1) ...
Purging configuration files for aptdaemon (1.1.1+bzr982-0ubuntu36) ...
Purging configuration files for python3-cupshelpers (1.5.15-0ubuntu1) ...
Purging configuration files for system-config-printer (1.5.15-0ubuntu1) ...
Purging configuration files for update-notifier (3.192.40) ...
Purging configuration files for ubuntu-advantage-tools (26.2) ...
Processing triggers for dbus (1.12.20-1ubuntu3) ...
  • 重新安装即可

使用aptitude 工具来解决依赖问题

references

安装aptitude工具

  • sudo apt-get install aptitude

使用aptitude安装指定包

  • sudo aptitude install <package-name>
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

cxxu1375

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值