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

1. There is a problem:

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. Reason analysis:

1. There is a problem with the installation package, you need to install the following installation package

 

2. The path problem, both relative path and absolute path are acceptable, refer to the following: image=cv2.imread("D:\\01xiangmu\\43tesseract\\IMG\\01.png") 

None of the above is a problem. I saw that these two situations were mentioned on the Internet, and neither of them could solve my problem. I directly suspected that there was a problem with the installation package. I wanted to download the source code and compile it, but it still couldn’t run normally. I encountered The most difficult problem, in the end, was found to be a conflict of installation packages:

3. Installation package conflict

The author originally had the opencv package, but installed the opencv-contrib-python package and the opencv-contrib-python-headless package without uninstalling it, which may cause python recognition errors, resulting in failure to recognize and run normally, and the above problems occur.

However, the author's opencv package cannot be uninstalled normally, whether through Pycham or Anaconda environment room pip uninstall, conda uninstall, conda remove cannot be uninstalled. . . .

Finally, go directly to C:\ProgramData\Anaconda3\envs\pytorch to find opencv, and find that it cannot be uninstalled, but the reason why conda list shows opencv is the opencv residue in C:\ProgramData\Anaconda3\envs\pytorch\conda-meta, as follows:

Delete it manually, conda list, found that opencv no longer exists.

At the same time, delete the opencv package in the base environment and search directly

 

After removing it, install it again

 

 Then pycham runs the program,

It's finally working!

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/yonghuming9527/article/details/128071085