cv2.error:If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or

python2以及python3 运行cv2.imshow(‘img’,img)的时候出现错误:

cv2.error: /io/opencv/modules/highgui/src/window.cpp:577: 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 cvDestroyAllWindows

原因分析:我之前用了pip install opencv-python==3.2.0.7 安装 以及 apt-get install libopencv-dev python-opencv(默认2.4)可能冲突了(猜测),具体原因我也不知道怎么回事

解决:opencv卸载重新安装
1.pip2 uninstall opencv-python / pip3 uninstall opencv-python
2.apt-get remove libopencv-dev python-opencv
3.sudo apt-get install libopencv-dev python-opencv

然后执行代码,没有问题

你可能感兴趣的:(cv2.error:If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or)