After installing opencv related libraries under conda, an error message appears when running. The function is not implemented. Rebuild the library with Windows, GTK+ 2.x

Here’s my solution first:

In the corresponding conda environment:

pip install opencv-python

Cause and effect:

After configuring a new environment, for convenience, I checked the opencv related items in Anaconda Navigator and installed it. In fact, there is no problem, after all, the query version is correct. We can also find related libraries after conda list. However, when running some basic opencv functions, an error will be reported, such as the imshow function, the error is as follows:

Traceback (most recent call last):
  File "d:\learn.py", line 17, in <module>
    cv2.imshow('Original Image', gray)
cv2.error: OpenCV(4.6.0) C:\b\abs_f8n1j3l9l0\croot\opencv-suite_1691622637237\work\modules\highgui\src\window.cpp:1267: 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'

I searched a lot on the Internet, and most of them suggested reinstalling through pip unintall python-opencv-headless. But obviously I haven't installed this here, so it has nothing to do with it. I just remembered that python-opencv seems to be installed in the conda library that I can run, but it was installed with pip. We can check the pip package in the current conda environment through pip list. After checking and comparing, we tried to install it with pip and it was successful. . As for the reason, it is difficult for me to go into details, so please forgive me.

Guess you like

Origin blog.csdn.net/weixin_55696427/article/details/134592141