# cv2.error: OpenCV(4.7.0) /tmp/opencv-4.7.0/modules/highgui/src/window.cpp:589: 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 'cvNamedWindow'

- **ID:** `opencv/highgui-window-already-exists`
- **Domain:** opencv
- **Category:** build_error
- **Error Code:** `-2`
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

OpenCV was built without GUI backend (GTK, Cocoa, or Windows) support, so highgui functions like imshow, namedWindow are unavailable.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 4.5.5 | active | — | — |
| 4.6.0 | active | — | — |
| 4.7.0 | active | — | — |
| 4.8.0 | active | — | — |
| 4.9.0 | active | — | — |

## Workarounds

1. **Install opencv-python with GUI support: `pip uninstall opencv-python-headless && pip install opencv-python`** (85% success)
   ```
   Install opencv-python with GUI support: `pip uninstall opencv-python-headless && pip install opencv-python`
   ```
2. **Install GTK development libraries and rebuild OpenCV from source: `sudo apt-get install libgtk2.0-dev pkg-config`, then `cmake -DWITH_GTK=ON .. && make`** (80% success)
   ```
   Install GTK development libraries and rebuild OpenCV from source: `sudo apt-get install libgtk2.0-dev pkg-config`, then `cmake -DWITH_GTK=ON .. && make`
   ```
3. **Use matplotlib to display images instead of OpenCV's highgui: `plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)); plt.show()`** (95% success)
   ```
   Use matplotlib to display images instead of OpenCV's highgui: `plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)); plt.show()`
   ```

## Dead Ends

- **** — Installing opencv-python-headless doesn't include GUI support; it's designed for headless environments. (90% fail)
- **** — Setting environment variables like DISPLAY doesn't add missing GUI backend code. (80% fail)
- **** — Using cv2.imshow in a Jupyter notebook still requires the GUI backend; the error persists. (70% fail)
