pyqt qt.qpa.plugin: Could not load the Qt platform plugin “xcb“ in ““ even though it was found.

2023-10-14 00:20

本文主要是介绍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.的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/206852

相关文章

springboot报错Invalid bound statement (not found)的解决

《springboot报错Invalidboundstatement(notfound)的解决》本文主要介绍了springboot报错Invalidboundstatement(not... 目录一. 问题描述二.解决问题三. 添加配置项 四.其他的解决方案4.1 Mapper 接口与 XML 文件不匹配

Python GUI框架中的PyQt详解

《PythonGUI框架中的PyQt详解》PyQt是Python语言中最强大且广泛应用的GUI框架之一,基于Qt库的Python绑定实现,本文将深入解析PyQt的核心模块,并通过代码示例展示其应用场... 目录一、PyQt核心模块概览二、核心模块详解与示例1. QtCore - 核心基础模块2. QtWid

Qt 中 isHidden 和 isVisible 的区别与使用小结

《Qt中isHidden和isVisible的区别与使用小结》Qt中的isHidden()和isVisible()方法都用于查询组件显示或隐藏状态,然而,它们有很大的区别,了解它们对于正确操... 目录1. 基础概念2. 区别清见3. 实际案例4. 注意事项5. 总结1. 基础概念Qt 中的 isHidd

QT移植到RK3568开发板的方法步骤

《QT移植到RK3568开发板的方法步骤》本文主要介绍了QT移植到RK3568开发板的方法步骤,文中通过图文示例介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一... 目录前言一、获取SDK1. 安装依赖2. 获取SDK资源包3. SDK工程目录介绍4. 获取补丁包二

Qt把文件夹从A移动到B的实现示例

《Qt把文件夹从A移动到B的实现示例》本文主要介绍了Qt把文件夹从A移动到B的实现示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学... 目录如何移动一个文件? 如何移动文件夹(包含里面的全部内容):如何删除文件夹:QT 文件复制,移动(

Maven pom.xml文件中build,plugin标签的使用小结

《Mavenpom.xml文件中build,plugin标签的使用小结》本文主要介绍了Mavenpom.xml文件中build,plugin标签的使用小结,文中通过示例代码介绍的非常详细,对大家的学... 目录<build> 标签Plugins插件<build> 标签<build> 标签是 pom.XML

Qt实现发送HTTP请求的示例详解

《Qt实现发送HTTP请求的示例详解》这篇文章主要为大家详细介绍了如何通过Qt实现发送HTTP请求,文中的示例代码讲解详细,具有一定的借鉴价值,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1、添加network模块2、包含改头文件3、创建网络访问管理器4、创建接口5、创建网络请求对象6、创建一个回复对

Qt 中集成mqtt协议的使用方法

《Qt中集成mqtt协议的使用方法》文章介绍了如何在工程中引入qmqtt库,并通过声明一个单例类来暴露订阅到的主题数据,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友一起看看吧... 目录一,引入qmqtt 库二,使用一,引入qmqtt 库我是将整个头文件/源文件都添加到了工程中进行编译,这样 跨平台

使用PyQt实现简易文本编辑器

《使用PyQt实现简易文本编辑器》这篇文章主要为大家详细介绍了如何使用PyQt5框架构建一个简单的文本编辑器,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录分析主窗口类 (MyWindow)菜单操作语法高亮 (SyntaxHighlighter)运行程序主要组件代码图示分析实现

基于Qt Qml实现时间轴组件

《基于QtQml实现时间轴组件》时间轴组件是现代用户界面中常见的元素,用于按时间顺序展示事件,本文主要为大家详细介绍了如何使用Qml实现一个简单的时间轴组件,需要的可以参考下... 目录写在前面效果图组件概述实现细节1. 组件结构2. 属性定义3. 数据模型4. 事件项的添加和排序5. 事件项的渲染如何使用