【发布时间】:2023-03-03 10:29:01
【问题描述】:
我正在学习在 PyQt5 上为 python 构建 GUI。我有一个程序,它使用 opencv 和 pyqt5 在 GUI 上显示带有人脸检测的网络摄像头,并具有启动和停止功能。但是发生了以下错误-
mayank@beware-hoax:~/PythonProjects/gui/pyqt5/pyqt5_face_detection$ source /home/mayank/anaconda3/bin/activate
conda activate gui
(base) mayank@beware-hoax:~/PythonProjects/gui/pyqt5/pyqt5_face_detection$ conda activate gui
/home/mayank/anaconda3/envs/gui/bin/python /home/mayank/PythonProjects/gui/pyqt5/pyqt5_face_detection/main_window.py
(gui) mayank@beware-hoax:~/PythonProjects/gui/pyqt5/pyqt5_face_detection$ /home/mayank/anaconda3/envs/gui/bin/python /home/mayank/PythonProjects/gui/pyqt5/pyqt5_face_detection/main_window.py
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" 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: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
Aborted (core dumped)
【问题讨论】:
-
记号应该是反引号 --> ``` ,而不是 -->''' 来格式化代码。
-
@MayankLad 执行:
export QT_DEBUG_PLUGINS=1并再次运行您的脚本,在这种情况下您会收到什么消息? -
@eyllanesc 我发现只有当我使用 Visual Studio 代码运行应用程序时才会出现此错误。当我通过 ubuntu 终端运行时,它运行良好!!
标签: python pyqt pyqt5 python-3.7