E: Unable to correct problems, you have held broken packages
问题:
apt install libmysqlclient-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:
libmysqlclient-dev : Depends: zlib1g-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
原因:
Linux下经常需要安装不同类型的库,在Ubuntu中,这些类库都是以“lib_name-version”的形式命名的。很多库之间存在依赖关系,即要安装这个就必须安装那个。有时候,类库之间依赖关系无法满足,你所要安装的程序就不能安装。
这类问题大多是由于相互依赖的几个库中一个或多个的版本已经更新,而用户要安装的库依赖于这几个库的较低的版本,这时候可以试试使用“sudo aptitude install ”(尖括号内为你要安装的程序的名字)
我这个问题就是因为
libmysqlclient-dev : 依赖: zlib1g-dev ,但是zlib1g-dev依赖了一个旧的包。
使用sudo apt-get install zlib1g-dev,观察到
zlib1g-dev : 依赖: zlib1g (= 1:1.2.8.dfsg-2ubuntu4) 但是 1:1.2.8.dfsg-2ubuntu4.1 已安装。
The following packages have unmet dependencies:
zlib1g-dev : Depends: zlib1g (= 1:1.2.8.dfsg-2ubuntu4) but 1:1.2.8.dfsg-2ubuntu4.1 is to be installed
E: Unable to correct problems, you have held broken packages.
解决办法:
使用aptitude
aptitude与 apt-get 一样,是 Debian 及其衍生系统中功能极其强大的包管理工具。与 apt-get 不同的是,aptitude在处理依赖问题上更佳一些。举例来说,aptitude在删除一个包时,会同时删除本身所依赖的包。这样,系统中不会残留无用的包,整个系统更为干净。
sudo aptitude install libmysqlclient-dev
运行后,不接受未安装方案,接受降级方案。搞定。