linux_ubuntu_apt install安装某些软件包出现的大量的依赖包版本不满足条件的问题@较全攻略(以ssh服务的安装为例)/软件包安装状态检查
文章目录
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>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了