以下是我遇到的错误。
cv2.error: OpenCV(4.7.0) D:\a\opencv-python\opencv-python\opencv\modules\highgui\src\window.cpp:1338: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvWaitKey'
WARNING: Environment does not support cv2.imshow() or PIL Image.show() image displays
OpenCV(4.7.0) D:\a\opencv-python\opencv-python\opencv\modules\highgui\src\window.cpp:1272: error: (-2:Unspecified error) The function is not implemented. Rebuild the
library with Windows, GTK+ 2.x or Cocoa 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'
环境是python3.8.5,opencv-python== 4.7.0,opencv-contrib-python==4.7.0我使用pycharm来操作yolov 5的摄像头检测,它告诉我“警告:环境不支持cv2.imshow()或PILImage.show()图像显示OpenCV(4.7.0)D:\a\opencv-python\opencv\modules\highgui\src\window.cpp:1272:错误:(-2:未指定的错误)未实现函数。请使用Windows、GTK+ 2.x或可可支持重新生成库。如果您使用的是Ubuntu或Debian,请安装libgtk2.0-dev和pkg-config,然后重新运行cmake或配置函数“cvShowImage”中的脚本
我试过重新安装opencv-python和opencv-contrib-python,但是无效。
1条答案
按热度按时间zkure5ic1#
我也遇到过类似的问题,但都是这样解决的:
更新PIP:
使用pip卸载opencv:
然后清除该高速缓存,因为PIP将保存卸载的版本,并只用它构建....(我花了一段时间才弄清楚)
接下来安装推荐的依赖项
最后,安装opencv-contrib-python。花了一段时间,但它对我很有效。我希望它能有所帮助!