解决给Ubuntu 18.04安装软件时的“unmet dependencies”问题

给Ubuntu 18.04安装软件时,会遇到类似下面的问题

The following packages have unmet dependencies:
 libvtk7-dev : Depends: libvtk7-java (= 7.1.1+dfsg1-2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

根据提示,逐步安装“Depends”后提示的软件包。最后,Ubuntu 18.04会安装要求的软件包,并删除冲突的软件包。
下面是根据这个办法,安装libvtk7-dev的过程。

$ sudo apt install libvtk7-dev
Reading package lists... Done
......
The following packages have unmet dependencies:
 libvtk7-dev : Depends: libvtk7-java (= 7.1.1+dfsg1-2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

$ sudo apt install libvtk7-java
Reading package lists... Done
Building dependency tree
Reading state information... Done
... ...
The following packages have unmet dependencies:
 libvtk7-java : Depends: libvtk7-jni (= 7.1.1+dfsg1-2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

$ sudo apt install libvtk7-jni
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libqt5x11extras5 libvtk7.1 libvtk7.1-qt
Suggested packages:
  vtk7-doc vtk7-examples
The following packages will be REMOVED:
  libpcl-dev libvtk6-dev libvtk6-java libvtk6-jni libvtk6-qt-dev
The following NEW packages will be installed:
  libqt5x11extras5 libvtk7-jni libvtk7.1 libvtk7.1-qt
0 upgraded, 4 newly installed, 5 to remove and 0 not upgraded.
Need to get 38.6 MB of archives.
After this operation, 127 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
......
Setting up libvtk7-jni (7.1.1+dfsg1-2) ...
Processing triggers for libc-bin (2.27-3ubuntu1.4) ...

另外,也可以使用命令“aptitude why-not software-package-name”, 输出中“Breaks”后的软件包,就是有冲突的软件包。卸载有冲突的软件包后,就可以直接安装需要的软件包。

posted @ 2022-01-21 09:42  HankFu  阅读(2222)  评论(0编辑  收藏  举报