ubuntu 安装依赖包时出现The following packages have unmet dependencies:

本人环境:ubuntu18.04 docker中安装opencv的依赖apt install libopencv-dev出现此问题:

Reading package lists... Done                                                                                   
Building dependency tree                                                                                        
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:                                                                 
 libopencv-dev : Depends: libopencv-calib3d2.4 but it is not going to be installed                              
                 Depends: libopencv-features2d2.4 but it is not going to be installed                           
                 Depends: libopencv-highgui2.4 but it is not going to be installed                              
                 Depends: libopencv-legacy2.4 but it is not going to be installed                               
                 Depends: libopencv-objdetect2.4 but it is not going to be installed                            
                 Depends: libopencv-objdetect-dev (= 2.4.9.1+dfsg-1+deb8u1) but it is not going to be installed 
                 Depends: libopencv-highgui-dev (= 2.4.9.1+dfsg-1+deb8u1) but it is not going to be installed   
                 Depends: libopencv-calib3d-dev (= 2.4.9.1+dfsg-1+deb8u1) but it is not going to be installed   
                 Depends: libopencv-features2d-dev (= 2.4.9.1+dfsg-1+deb8u1) but it is not going to be installed
                 Depends: libopencv-legacy-dev (= 2.4.9.1+dfsg-1+deb8u1) but it is not going to be installed    
                 Depends: libopencv-contrib-dev (= 2.4.9.1+dfsg-1+deb8u1) but it is not going to be installed   
                 Depends: libopencv-ts-dev (= 2.4.9.1+dfsg-1+deb8u1) but it is not going to be installed        
                 Depends: libopencv-videostab-dev (= 2.4.9.1+dfsg-1+deb8u1) but it is not going to be installed 
                 Depends: libopencv-stitching-dev (= 2.4.9.1+dfsg-1+deb8u1) but it is not going to be installed 
                 Depends: libopencv-superres-dev (= 2.4.9.1+dfsg-1+deb8u1) but it is not going to be installed  
                 Depends: libopencv-ocl-dev (= 2.4.9.1+dfsg-1+deb8u1) but it is not going to be installed       
                 Depends: libopencv2.4-java (= 2.4.9.1+dfsg-1+deb8u1) but it is not going to be installed       
                 Depends: libopencv2.4-jni (= 2.4.9.1+dfsg-1+deb8u1) but it is not going to be installed        
                 Depends: libcv-dev (= 2.4.9.1+dfsg-1+deb8u1) but it is not going to be installed               
                 Depends: libhighgui-dev (= 2.4.9.1+dfsg-1+deb8u1) but it is not going to be installed          
                 Depends: libcvaux-dev (= 2.4.9.1+dfsg-1+deb8u1) but it is not going to be installed            
E: Unable to correct problems, you have held broken packages.                                                   

原因:刚才服务器下建立的容器,里面的源比较老,搜索不到上述依赖包
解决:打开软件源配置文件

vim /etc/apt/sources.list

打开后输入

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

保存退出后,利用下述命令更新

sudo apt-get update

更新后依赖包正常安装

当您在Linux系统中安装软件包时,可能会遇到“以下软件包存在未满足的依赖关系”的错误消息。这通常是由于软件包之间的依赖关系无法满足而导致的。以下是一些解决这个问题的常见方法: 1. 更新软件包列表:在终端中运行以下命令: ``` $ sudo apt-get update ``` 这将更新软件包列表,以确保您的系统可以找到最新的软件包。 2. 安装缺失的依赖项:在终端中运行以下命令: ``` $ sudo apt-get install -f ``` 这将自动安装缺失的依赖项。 3. 安装特定版本的软件包:有时,特定版本的软件包可以满足依赖关系。您可以使用以下命令安装特定版本的软件包: ``` $ sudo apt-get install <package-name>=<package-version> ``` 例如,要安装Python的2.7.17版本,您可以使用以下命令: ``` $ sudo apt-get install python2.7=2.7.17-1~18.04ubuntu1 ``` 4. 删除冲突的软件包:有时,其他软件包可能与您要安装的软件包发生冲突。您可以尝试使用以下命令删除冲突的软件包: ``` $ sudo apt-get remove <package-name> ``` 例如,要删除与Python 2.7.17发生冲突的Python 3.6软件包,您可以使用以下命令: ``` $ sudo apt-get remove python3.6 ``` 5. 清理未使用的软件包:在终端中运行以下命令: ``` $ sudo apt-get autoclean $ sudo apt-get autoremove ``` 这将清除系统中未使用的软件包和依赖项。 希望这些方法可以帮助您解决“以下软件包存在未满足的依赖关系”的错误消息。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值