conda安装的opencv3.4.2解决cv2的Rebuild the library with Windows, GTK+ 2.x or Carbon support问题

用anaconda直接安装的opencv库,在调用cv2.namedWindow()时会报错。

cv2.error: /tmp/build/80754af9/opencv_1512687413662/work/modules/highgui/src/window.cpp:593: 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 cvNamedWindow

搜索问题后发现原因是conda安装的opencv是阉割版的,详情可见https://blog.csdn.net/aaon22357/article/details/81913465

不能实现视频和摄像头的读取功能。解决方案网上大多给出的是卸载conda的opencv,然后手动编译安装opencv,但是我是先安装的anaconda,在编译opencv时出现很多问题,导致编译失败,之后在知乎上看到对应的解决方案,非常方便,详情见https://www.zhihu.com/question/263917089

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

之后问题解决。
————————————————
版权声明:本文为CSDN博主「lipyiduost」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_29633355/article/details/90452104

你可能感兴趣的:(开发所遇问题,windows,opencv,python)