本文主要是介绍pyqt qt.qpa.plugin: Could not load the Qt platform plugin “xcb“ in ““ even though it was found.,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
当我玩一下 PyQt 时,问题出现了
问题代码:
#! /usr/bin/env python
# -*- coding: utf-8 -*-import sys
from PyQt5 import QtWidgets, QtCoreif __name__ == '__main__':app = QtWidgets.QApplication(sys.argv)widget = QtWidgets.QWidget()widget.resize(320, 240)widget.setWindowTitle("Hello PyQt5")widget.show()sys.exit(app.exec_())
报错
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.已放弃
先看详细的报错信息
export QT_DEBUG_PLUGINS=1
报错:
Found metadata in lib /home/gfdgd_xi/.local/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqeglfs.so, metadata=
{"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3","MetaData": {"Keys": ["eglfs"]},"archreq": 0,"className": "QEglFSIntegrationPlugin","debug": false,"version": 331520
}Found metadata in lib /home/gfdgd_xi/.local/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqlinuxfb.so, metadata=
{"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3","MetaData": {"Keys": ["linuxfb"]},"archreq": 0,"className": "QLinuxFbIntegrationPlugin","debug": false,"version": 331520
}Found metadata in lib /home/gfdgd_xi/.local/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqminimal.so, metadata=
{"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3","MetaData": {"Keys": ["minimal"]},"archreq": 0,"className": "QMinimalIntegrationPlugin","debug": false,"version": 331520
}Found metadata in lib /home/gfdgd_xi/.local/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqminimalegl.so, metadata=
{"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3","MetaData": {"Keys": ["minimalegl"]},"archreq": 0,"className": "QMinimalEglIntegrationPlugin","debug": false,"version": 331520
}Found metadata in lib /home/gfdgd_xi/.local/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqoffscreen.so, metadata=
{"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3","MetaData": {"Keys": ["offscreen"]},"archreq": 0,"className": "QOffscreenIntegrationPlugin","debug": false,"version": 331520
}Found metadata in lib /home/gfdgd_xi/.local/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqvnc.so, metadata=
{"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3","MetaData": {"Keys": ["vnc"]},"archreq": 0,"className": "QVncIntegrationPlugin","debug": false,"version": 331520
}Found metadata in lib /home/gfdgd_xi/.local/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqwayland-egl.so, metadata=
{"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3","MetaData": {"Keys": ["wayland-egl"]},"archreq": 0,"className": "QWaylandEglPlatformIntegrationPlugin","debug": false,"version": 331520
}Found metadata in lib /home/gfdgd_xi/.local/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqwayland-generic.so, metadata=
{"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3","MetaData": {"Keys": ["wayland"]},"archreq": 0,"className": "QWaylandIntegrationPlugin","debug": false,"version": 331520
}Found metadata in lib /home/gfdgd_xi/.local/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqwayland-xcomposite-egl.so, metadata=
{"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3","MetaData": {"Keys": ["wayland-xcomposite-egl"]},"archreq": 0,"className": "QWaylandXCompositeEglPlatformIntegrationPlugin","debug": false,"version": 331520
}Found metadata in lib /home/gfdgd_xi/.local/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqwayland-xcomposite-glx.so, metadata=
{"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3","MetaData": {"Keys": ["wayland-xcomposite-glx"]},"archreq": 0,"className": "QWaylandXCompositeGlxPlatformIntegrationPlugin","debug": false,"version": 331520
}Found metadata in lib /home/gfdgd_xi/.local/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqwebgl.so, metadata=
{"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3","MetaData": {"Keys": ["webgl"]},"archreq": 0,"className": "QWebGLIntegrationPlugin","debug": false,"version": 331520
}Found metadata in lib /home/gfdgd_xi/.local/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so, metadata=
{"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3","MetaData": {"Keys": ["xcb"]},"archreq": 0,"className": "QXcbIntegrationPlugin","debug": false,"version": 331520
}QLibraryPrivate::loadPlugin failed on "/home/gfdgd_xi/.local/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so" : "Cannot load library /home/gfdgd_xi/.local/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxcb-util.so.1: 无法打开共享对象文件: 没有那个文件或目录)"
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.已放弃
缺库
在https://forum.qt.io/topic/93247/qt-qpa-plugin-could-not-load-the-qt-platform-plugin-xcb-in-even-though-it-was-found/100看到了解决方案,输入以下内容即可:
sudo apt install -qq libglu1-mesa-dev libx11-xcb-dev '^libxcb*'
附图:
附 PyQt5 安装方法:
python3 -m pip install PyQt5
这篇关于pyqt qt.qpa.plugin: Could not load the Qt platform plugin “xcb“ in ““ even though it was found.的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!