pyqt5:无法连接到显示器

问题描述 投票:0回答:1

我正在学习在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)
python pyqt pyqt5 python-3.7
1个回答
0
投票

这绝对不是最好的解决方案,但是我同样遇到了无法从代码运行的问题,并且在终端上运行良好。无论如何,我以root特权启动了vs代码,我克服了这个问题,并启动了GUI。但是,由于安全问题,因此不建议这样做。

类似这样的东西:How to open Visual Studio Code with admin privileges to make effect of the installed extensions

我认为我的anaconda文件夹位置可能与此有关。我希望有人对此提供真正的答案]

© www.soinside.com 2019 - 2024. All rights reserved.