还有人见过这个问题吗?我正在尝试在 Ubuntu Xenial LTS 中安装 OpenCV。
我尝试取消注释 /etc/apt/sources.list 中的 deb-src 条目,但仍然不起作用。
sudo apt-get -f 安装 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-objdetect-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but it is not going to be installed
Depends: libopencv-highgui-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but it is not going to be installed
Depends: libopencv-legacy-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but it is not going to be installed
Depends: libopencv-contrib-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but it is not going to be installed
Depends: libopencv-videostab-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but it is not going to be installed
Depends: libopencv-superres-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but it is not going to be installed
Depends: libopencv-ocl-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but it is not going to be installed
Depends: libcv-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but it is not going to be installed
Depends: libhighgui-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but it is not going to be installed
Depends: libcvaux-dev (= 2.4.9.1+dfsg-1.5ubuntu1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
答案1
请尝试以下操作:sudo aptitude install libopencv-dev
当您收到询问解决依赖关系的问题时,您将看到 (Y/n/q)?。输入 n。
看看下一个 (Y/n/q) 问题是什么。通常这部分会降级其中一个依赖项,以便解决其他依赖项。这对我来说很有效!希望对你也一样。
答案2
使用 aptitude 而不是 apt-get。它更智能。它不仅可以帮您处理冲突软件包的降级,还会提出一系列建议,询问您希望使用众多可能的建议工作方案中的哪一种。
sudo aptitude install myNewPackage
如果你的机器上还没有 aptitude,可以使用
sudo apt-get install aptitude