python的opencv错误The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon

1、出现问题:

cv2.error: OpenCV(4.5.4-dev) D:\a\opencv-python\opencv-python\opencv\modules\highgui\src\window.cpp:1274: error: (-2:Unspecified e
rror) 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'

2、原因分析:

1、安装包问题,需要安装以下安装包

python的opencv错误The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon_第1张图片

 

2、路径问题 ,相对路径和绝对路径都可以,参考如下:image=cv2.imread("D:\\01xiangmu\\43tesseract\\IMG\\01.png") 

以上均没问题,一看网上面均说的是这两种情况,均无法解决笔者问题,搞得笔者直接怀疑是不是安装包有问题,直接想下载源码编译,仍无法正常运行,笔者遇到了最棘手的问题,最后竟然发现是安装包冲突问题:

3、安装包冲突问题

python的opencv错误The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon_第2张图片

python的opencv错误The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon_第3张图片

笔者原先有opencv包,没有卸载干净,就安装opencv-contrib-python包和opencv-contrib-python-headless包,可能导致python识别错误,导致无法正常识别运行,出现上述问题。

但是笔者的opencv包竟然无法正常卸载,无论通过Pycham或者Anaconda环境房间pip uninstall、conda uninstall、conda remove 均无法卸载。。。。

最后直接到C:\ProgramData\Anaconda3\envs\pytorch中查找opencv,发现无法卸载,conda list却显示opencv的原因是C:\ProgramData\Anaconda3\envs\pytorch\conda-meta中的opencv残留,如下:

python的opencv错误The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon_第4张图片

将其手动删除,conda list,发现已经不存在opencv。

python的opencv错误The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon_第5张图片

同时,将base环境下的opencv包删除,直接搜索

 

python的opencv错误The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon_第6张图片

删除干净后,再次安装

 python的opencv错误The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon_第7张图片

 然后pycham运行程序,

python的opencv错误The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon_第8张图片

终于正常运行!

 

 

 

 

 

 

你可能感兴趣的:(opencv,python,人工智能,计算机视觉)