{
  "id": "opencv/highgui-window-already-exists",
  "signature": "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'",
  "signature_zh": "cv2.error: OpenCV(4.7.0) /tmp/opencv-4.7.0/modules/highgui/src/window.cpp:589: error: (-2:未指定错误) 功能未实现。请使用 Windows、GTK+ 2.x 或 Cocoa 支持重新编译库。如果您在 Ubuntu 或 Debian 上，请安装 libgtk2.0-dev 和 pkg-config，然后重新运行 cmake 或配置脚本 在函数 'cvNamedWindow' 中",
  "regex": "The function is not implemented.*Rebuild the library with.*GTK",
  "domain": "opencv",
  "category": "build_error",
  "subcategory": null,
  "root_cause": "OpenCV was built without GUI backend (GTK, Cocoa, or Windows) support, so highgui functions like imshow, namedWindow are unavailable.",
  "root_cause_type": "generic",
  "root_cause_zh": "OpenCV 在构建时没有包含 GUI 后端（GTK、Cocoa 或 Windows）支持，因此 imshow、namedWindow 等高 GUI 函数不可用。",
  "versions": [
    {
      "version": "4.5.5",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "4.6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "4.7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "4.8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "4.9.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Installing opencv-python-headless doesn't include GUI support; it's designed for headless environments.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Setting environment variables like DISPLAY doesn't add missing GUI backend code.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Using cv2.imshow in a Jupyter notebook still requires the GUI backend; the error persists.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Install opencv-python with GUI support: `pip uninstall opencv-python-headless && pip install opencv-python`",
      "success_rate": 0.85,
      "how": "Install opencv-python with GUI support: `pip uninstall opencv-python-headless && pip install opencv-python`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Install GTK development libraries and rebuild OpenCV from source: `sudo apt-get install libgtk2.0-dev pkg-config`, then `cmake -DWITH_GTK=ON .. && make`",
      "success_rate": 0.8,
      "how": "Install GTK development libraries and rebuild OpenCV from source: `sudo apt-get install libgtk2.0-dev pkg-config`, then `cmake -DWITH_GTK=ON .. && make`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use matplotlib to display images instead of OpenCV's highgui: `plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)); plt.show()`",
      "success_rate": 0.95,
      "how": "Use matplotlib to display images instead of OpenCV's highgui: `plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)); plt.show()`",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Install opencv-python with GUI support: `pip uninstall opencv-python-headless && pip install opencv-python`",
    "Install GTK development libraries and rebuild OpenCV from source: `sudo apt-get install libgtk2.0-dev pkg-config`, then `cmake -DWITH_GTK=ON .. && make`",
    "Use matplotlib to display images instead of OpenCV's highgui: `plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)); plt.show()`"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.opencv.org/4.x/d7/dfc/group__highgui.html",
  "official_doc_section": null,
  "error_code": "-2",
  "verification_tier": "ai_generated",
  "confidence": 0.92,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-02-28",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}