一、树莓派、Linux、Ubuntu问题集合
1、Unable to correct problems, you have held broken packages.
①The following packages have unmet dependencies:
aptitude : Depends: libapt-pkg5.0 (>= 1.1) but it is not going to be installed
Recommends: libparse-debianchangelog-perl but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
②sudo apt-get install aptitude安装包报错:The following packages have unmet dependencies
1 问题描述
我按照此教程:为树莓派更换国内镜像源,更换树莓派镜像源为国内的 清华源 后,在使用 sudo apt-get install aptitude
时,出现依赖包错误的问题,具体错误信息如下:
<span style="color:#000000"><span style="background-color:#282c34"><code class="language-shell">pi@raspberrypi:~ $ <span style="color:#61aeee">sudo</span> <span style="color:#61aeee">apt-get</span> <span style="color:#61aeee">install</span> <span style="color:#61aeee">aptitude</span>
Reading package lists<span style="color:#999999">..</span>. Done
Building dependency tree
Reading state information<span style="color:#999999">..</span>. Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or <span style="color:#c678dd">if</span> 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 <span style="color:#61aeee">help</span> to resolve the situation:
The following packages have unmet dependencies:
<span style="color:#61aeee">aptitude</span> <span style="color:#c678dd">:</span> Depends: libapt-pkg5.0 <span style="color:#999999">(</span><span style="color:#669900">>=</span> 1.1<span style="color:#999999">)</span> but it is not going to be installed
Recommends: libparse-debianchangelog-perl but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
</code></span></span>
当出现此错误的时候,我也是找了很久,还去论坛上发帖求助(论坛传送门:树莓派更换清华源,安装aptitude报错),但是都没有得到有用的答案。
2 问题原因
经过不懈的查找原因,终于在一篇文章中发现了些许端倪,文章链接:树莓派失败到放弃!,相关信息截图如下:
看到这里,我突然想到,我自己就是在网上百度一个换源的方法,直接就用了,也没管是哪个版本,好了,那么原因应该就是这个。
3 问题解决
首先我使用命令: lsb_release -a
,查看当前树莓派系统版本,具体信息如下,此版本的代号为 “buster”
<span style="color:#000000"><span style="background-color:#282c34"><code class="language-shell">pi@raspberrypi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 10 <span style="color:#999999">(</span>buster<span style="color:#999999">)</span>
Release: 10
Codename: buster
</code></span></span>
然后我去看了一下使用镜像源的地址,使用的版本代号为 “stretch” ,如下
<span style="color:#000000"><span style="background-color:#282c34"><code class="language-shell">deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
</code></span></span>
于是,我去对应文件,把 stretch
修改为 buster
,大功告成✌️✌️✌️!
修改完毕后,记得执行如下命令,更新软件源列表!
<span style="color:#000000"><span style="background-color:#282c34"><code class="language-shell"><span style="color:#61aeee">sudo</span> <span style="color:#61aeee">apt-get</span> update
<span style="color:#61aeee">sudo</span> <span style="color:#61aeee">apt-get</span> upgrade
</code></span></span>
此时,应该会有很多东西需要更新,慢慢等待即可,国内镜像源网速还是挺好的;
更新完毕之后,即可再次安装 aptitude
,使用如下命令:
<span style="color:#000000"><span style="background-color:#282c34"><code class="language-shell"><span style="color:#61aeee">sudo</span> <span style="color:#61aeee">apt-get</span> <span style="color:#61aeee">install</span> <span style="color:#61aeee">aptitude</span>
</code></span></span>
大功告成✌️✌️✌️,我终于解决了这个该死的问题,希望对你有所帮助!