Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

opencv crashes in Linux when used with webbrowser lib

未关闭
#1,215 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
opencv, python

调研方向

从 test.py 中的最小复现开始,在安装 opencv-python 后于 Python 3.13 虚拟环境中运行它。将其行为与 opencv-python-headless 以及列出的 QT_QPA_PLATFORM 变通方案进行比较;完成意味着已解决文档所述的软件包行为,或已明确处理崩溃和受支持的配置。

由索引模型根据 Issue 内容生成。

描述

minmal example

tested on ubuntu 2024.04lts with python3.13

save this file as test.py

import cv2
# other code where i need cv2 ommited
server_name="https://localhost:8080"
if __name__ == "__main__":
    import webbrowser
    if server_name.startswith("http"):
        url = server_name
    else:
        url = "http://" + server_name
    webbrowser.open(url , new = 0, autoraise = True)

now run it in a venv with only opencv installed

$python3.13 -m venv .envlin
$ . .envlin/bin/activate
(.envlin)$ pip install opencv_python
Collecting opencv_python
  Downloading opencv_python-4.13.0.92-cp37-abi3-manylinux_2_28_x86_64.whl.metadata (19 kB)
Collecting numpy>=2 (from opencv_python)
  Downloading numpy-2.4.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.metadata (6.6 kB)
Downloading opencv_python-4.13.0.92-cp37-abi3-manylinux_2_28_x86_64.whl (72.9 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 72.9/72.9 MB 7.3 MB/s  0:00:10
Downloading numpy-2.4.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (16.6 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 16.6/16.6 MB 7.0 MB/s  0:00:02
Installing collected packages: numpy, opencv_python
Successfully installed numpy-2.4.4 opencv_python-4.13.0.92
$ python test.py 
QObject::moveToThread: Current thread (0x57e4655873d0) is not the object's thread (0x57e4655abf40).
Cannot move to target thread (0x57e4655873d0)

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/cv2test/.envlin/lib/python3.13/site-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx.

Aborted (core dumped)
workarounds

some workarounds i have found:

  • people worked around by setting the variable export QT_QPA_PLATFORM=offscreen ( https://github.com/Evezerest/PPOCRLabel/issues/61 ) to one of he values in the error message. some work and "fix" it some dont.. but it should not be a guessing game.. should also not be the standard behavior to crash. I had hoped a virtual environment gives one the possibility to isolate the env.
  • deinstalling opencv-python and installing opencv-python-headless if you only need calculations also work. but the issue is that any library listing opencv-python as dependency will install it (this is specially true in "living" projects like comfyui). maybe one could install a place holser "none" lib
similar issues

this problem seems to exist since at least 2017: https://github.com/opencv/opencv-python/issues/46

@skvark any chance of a fix in the meanwhile?

主要语言
Python
星标
5.4k
派生
1k
平均合并
22 小时 17 分钟
30 天内合并 PR
3

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

opencv/opencv-python 的其他 Issue

查看 opencv/opencv-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。