openCV不能与python3一起使用

openCV不能与python3一起使用,python,opencv,ubuntu,Python,Opencv,Ubuntu,我在ubuntu 16.10上运行简单的Python3和opencv程序时遇到这个错误 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-

我在ubuntu 16.10上运行简单的Python3和opencv程序时遇到这个错误

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 583 Traceback (most
recent call last):   File "samplecv.py", line 3, in <module>
    cv2.imshow('image',img) cv2.error: /io/opencv/modules/highgui/src/window.cpp:583: 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,但没有任何帮助。

您尝试的方法更适合python2。您正在使用python3(从您的问题中我可以看出)。我猜您正在使用pip3安装命令安装cv模块。它可以工作,但为模块提供了减少的功能:正如您在highgui模块中看到的 函数未实现。”


解决方案:尝试第一个答案,并按照说明一步一步手动安装opencv模块。

花了2个多小时,但现在已经完成! 我查阅了opencv的文档,并按照步骤安装了opencv 3.3.0-dev。 在完成安装后,它仍然无法工作,因此我使用

现在没有显示错误,但直到我添加错误后,图像才显示出来

在节目结束时。
现在它的工作很好

如果您是通过pythonpip安装OpenCV的,那么您将无法在屏幕上显示图像,从而导致这些错误。您唯一的选择是编译源代码以生成正确的Python包,以便显示图像。PyImageSearch中的这些说明非常好:。根据您的系统配置和设置,准备花费30分钟到一小时的时间。感谢您现在就完成了。
cmake-D cmake\u BUILD\u TYPE=RELEASE \-D cmake\u INSTALL\u PREFIX=/usr/local \-D INSTALL\u C\u EXAMPLES=on \-D INSTALL\u PYTHON\u EXAMPLES=on \-D OPENCV\u EXTRA\u MODULES\u PATH=~/OPENCV\u contrib/MODULES \-D构建示例=基于
。。他犯了错误。不管怎样,我已经解决了,谢谢你!是,您必须使用
waitKey
。很多用户忘记了这样做。
  import cv2
    img = cv2.imread('my.jpg',0)
    cv2.imshow('image',img)
sudo pip3 uninstall opencv-python
cv2.waitKey()