Ubuntu16.04 使用Anaconda安装opencv后imshow失败

Ubuntu16.04系统,使用Anaconda的conda install安装opencv,安装完后import cv2没问题,但是执行cv2.imwrite("test.png", img) 和cv2.imshow("Img", img)时提示错误:

error:

(OpenCV 3.4.2)/tmp/build/80754af9/opencv_1512687413662/work/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

解决方案:

conda remove opencv
conda install -c menpo opencv
pip install --upgrade pip
pip install opencv-contrib-python

你可能感兴趣的:(Ubuntu16.04 使用Anaconda安装opencv后imshow失败)