我正在尝试一个OpenCV教程,当我运行python代码时出现了这个错误
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvShowImage, file /home/pankaja/Desktop/OpenCV-tmp/opencv/modules/highgui/src/window.cpp, line 611
Traceback (most recent call last):
File "/home/pankaja/PycharmProjects/ImageProcessing/imageprocess.py", line 8, in <module>
cv2.imshow('image', img)
cv2.error: /home/pankaja/Desktop/OpenCV-tmp/opencv/modules/highgui/src/window.cpp:611: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvShowImage
至于OpenCV error: the function is not implemented这个stackoverflow的答案,我尝试了命令 sudo apt-get install libopencv - * 并得到了这个,
*The following packages have unmet dependencies:
libopencv-apps-dev : Depends: libcv-bridge-dev but it is not going to be installed
Depends: libdynamic-reconfigure-config-init-mutex-dev but it is not going to be installed
Depends: libimage-transport-dev but it is not going to be installed
Depends: libnodeletlib-dev but it is not going to be installed
Depends: libroscpp-dev but it is not going to be installed
libopencv-highgui-dev : Depends: libgtk2.0-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.*
如何解决这个问题?我做错了什么?
编辑1:运行 sudo apt-get install -f 之后,@ Jeer Luke提到
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libenca0 librubberband2v5 libva-wayland1 linux-headers-4.10.0-27 linux-headers-4.10.0-27-generic linux-headers-4.10.0-30
linux-headers-4.10.0-30-generic linux-headers-4.4.0-89 linux-headers-4.4.0-89-generic linux-headers-4.4.0-92 linux-headers-4.4.0-92-generic
linux-image-4.10.0-27-generic linux-image-4.10.0-30-generic linux-image-4.4.0-89-generic linux-image-4.4.0-92-generic
linux-image-extra-4.10.0-27-generic linux-image-extra-4.10.0-30-generic linux-image-extra-4.4.0-89-generic
linux-image-extra-4.4.0-92-generic linux-signed-image-4.10.0-27-generic linux-signed-image-4.10.0-30-generic mpv rtmpdump
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
运行 sudo apt-get install libopencv - *
时仍然出现错误编辑2:运行 sudo apt-get install libgtk-3-dev 命令后,@ Zindarod提到
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:
libgtk-3-dev : Depends: libgtk-3-0 (= 3.18.9-1ubuntu3) but 3.18.9-1ubuntu3.3 is to be installed
Depends: gir1.2-gtk-3.0 (= 3.18.9-1ubuntu3) but 3.18.9-1ubuntu3.3 is to be installed
Depends: libatk-bridge2.0-dev but it is not going to be installed
Depends: libepoxy-dev (>= 1.0) but it is not going to be installed
Depends: libegl1-mesa-dev but it is not going to be installed
Depends: libwayland-dev (>= 1.5.91) but it is not going to be installed
Depends: libmirclient-dev (>= 0.13.3) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
仍然没有运气