当前位置: 代码迷 >> 综合 >> Gtk-ERROR **: 13:39:35.637: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process
  详细解决方案

Gtk-ERROR **: 13:39:35.637: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process

热度:51   发布时间:2024-02-05 16:31:30.0

环境:Ubuntu18.04 pycharm pip安装的opencv4.3.0.36

问题:一使用cv2.imshow这种需要创建图形界面的函数就报错

报错信息:Gtk-ERROR **: 13:39:35.637: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported

输入

pkg-config --libs gtk+-3.0

输出结果:

-lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0

输入

pkg-config --libs gtk+-2.0 clutter-gtk-1.0 gthread-2.0

输出

Package gtk+-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk+-2.0' found
Package clutter-gtk-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `clutter-gtk-1.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'clutter-gtk-1.0' found

看起来我应该只有gtk3.0 不知道怎么回事

慌乱尝试:

1.更换opencv版本 卸载重新安装opencv-python 3.2.0.7

报另外的错误

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 /io/opencv/modules/highgui/src/window.cpp, line 545
Traceback (most recent call last):File "/home/qichang/PycharmProjects/hourglass-facekeypoints-detection/genHeatmap_300w.py", line 39, in <module>cv2.imshow('result', img)
cv2.error: /io/opencv/modules/highgui/src/window.cpp:545: 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-contrib-python 装了以后还是报这个错误

按照报错信息装一下libgtk2.0-dev

sudo apt  install libgtk2.0-dev

重新编译了一下opencv 不知道怎么回事他只能装到python2里面去 搞不懂 暂时放弃

  相关解决方案