python - pyqt5:无法连接到显示器
问题描述
我正在学习在 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)
解决方案
这绝对不是最好的解决方案,但我遇到了同样的问题,即无法从代码运行,并且在终端上运行良好。无论如何,我以 root 权限启动了 vs 代码,我能够克服这个问题并且我的 GUI 启动了。但是,由于安全问题,不建议这样做,这是正确的。
像这样:如何以管理员权限打开 Visual Studio Code 以使已安装的扩展生效
我认为我的 anaconda 文件夹位置可能与此有关。我希望有人对此提供真正的答案
推荐阅读
- splunk - Splunk 中的节中的无效键
- python - 为什么我的代码在提取字符串时无法在 Python 正则表达式中运行
- c++ - 如何在 QML 中拍摄多张照片?
- c++ - 在 C++ 中自动化控制台输入
- javascript - 如何在 highcharts 导出服务器中实现时区独立性?
- .htaccess - 尝试访问我的网站时,它显示访问被禁止
- java - 从edittext获取数值的替代方法
- javascript - 从 chrome 扩展发布数据
- node.js - 将文件从一个文件夹移动到s3中的另一个文件夹
- javascript - JavaScript onload() 函数