Ubuntu20.04下解决Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“ 问题

这篇具有很好参考价值的文章主要介绍了Ubuntu20.04下解决Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“ 问题。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

问题描述

python调用matplotlib.pyplot库进行图形绘制时弹出错误提示:

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, xcb.
 
Aborted (core dumped)

根据问题描述,能够找到但不能加载Qt平台插件“xcb”;虽然接下来又说重新安装可能能够解决,但还是尽量避免重装吧。


定位问题

修改配置文件~/.bashrc:

$ vim ~/.bashrc

在最末尾添加如下语句,会在执行程序时,列出详细的错误提示:

export QT_DEBUG_PLUGINS=1

如下:
Ubuntu20.04下解决Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“ 问题
保存退出编辑,使配置文件生效:

$ source ~/.bashrc

重新执行程序,便能看到详细的错误信息:
Ubuntu20.04下解决Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“ 问题
在打印的错误信息的最下几行,能看到引发错误的真正原因:
Ubuntu20.04下解决Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“ 问题
也就是Qt动态链接库的问题,当加载libqxcb.so库的时候,还需要加载libxcb-icccm库。
切换到报错libxcb.so所在目录

#替换为自己的报错目录
$ cd /home/your_file_directory/plugins/platforms/

运行ldd libqxcb.so,查看关联内容:

$ ldd libqxcb.so

Ubuntu20.04下解决Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“ 问题
能发现,除了错误信息中显示的libxcb-libxcb-icccm.so.4库不存在,也存在其他依赖库没安装的现象,需要一并安装。


解决方法

安装libxcb-libxcb-icccm等缺失的库:

#注意需要把库名之后的版本号一并加上
$ sudo apt-get install libxcb-icccm4

安装完成后,再次查看关联内容,发现已经修复问题:

$ ldd libqxcb.so

Ubuntu20.04下解决Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“ 问题
再次运行程序,即正常了。
Ubuntu20.04下解决Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“ 问题


后续

会发现每次执行程序时都会有详细提示,于后续代码调试不利,所以需要将添加到配置文件~/.bashrc最后一行的语句删除,保存退出后重新使配置文件生效(详细过程见上“定位问题”一节)。文章来源地址https://www.toymoban.com/news/detail-440613.html

到了这里,关于Ubuntu20.04下解决Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“ 问题的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 关于qt.qpa.plugin: Could not find the Qt platform plugin “windows“ in ““问题的解决

    我再安装matplotlib使用的是anaconda直接安装的,这个包会自带一个QTdesigner,和我原先环境内的pyside2冲突。当我卸载matplotlib后就发生上述报错。 问题很简单,就是程序找不到plugin插件了 向环境变量里添加 这个方案在别的文章里很容易找到 但这个也会出现一个问题,就是自己电

    2024年02月08日
    浏览(52)
  • 【已解决】qt.qpa.plugin: Could not load the Qt platform plugin “windows“ in ““ even though it was found.

    在加载labelimg的时候出现报错: qt.qpa.plugin: Could not load the Qt platform plugin “windows” 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. 翻译:Qt .qpa.plugin:无法在“”中加载Qt平台插件“windows”,即

    2024年02月07日
    浏览(44)
  • qt.qpa.plugin: Could not load the Qt platform plugin “xcb“ in ““ even though it was found.(解决办法)

    环境:ubuntu16.04  报错:(在以安装pyqt5的情况下) 完美解决!!!

    2024年02月16日
    浏览(37)
  • qt.qpa.plugin:找不到Qt平台插件“wayland“|| (下载插件)Ubuntu上解决方案

    相信大家也都知道这个地方应该做什么,当然是下载这个qt平台的插件wayland,但是很多人可能不知道怎么下载这个插件。 那么我现在要说的这个方法就是针对这种的。 完事儿了奥兄弟们。 看看效果 正常了奥。

    2024年02月10日
    浏览(38)
  • qt.qpa.plugin:Could not load the Qt platform plugin “xcb“

    提示信息:  错误信息中提到“\\\"/home/zxq/anaconda3/envs/open3d/lib/python3.9/site-packages/cv2/qt/plugins”  解决办法1 :首先按照提示信息的建议“Reinstalling the application may fix this problem.”,卸载原来的opencv,一般都能解决。 解决办法2 :删除上面目录中的libqxcb.so文件即可 解决办法3 :尝

    2024年02月03日
    浏览(45)
  • qt.qpa.plugin: Could not load the Qt platform plugin “xcb“

    在服务器远程运行会弹出窗口显示画面的代码时,可能遇到上述报错 首先执行`export QT_DEBUG_PLUGINS=1`,再运行一次导致报错的代码。可以看到详细错误信息,我这里看到具体错误为:  少了这样一个包,但是直接`apt-get update`,`apt-get install libxcb-icccm`是找不到的。此时应该执行

    2024年03月27日
    浏览(38)
  • qt.qpa.plugin: Could not load the Qt platform plugin “xcb“ in

    兄弟们看看是不是这个错: VScode 80年不出个错,今儿冒出来这个,我也不知道是mmdet配置问题,还是opencv-python的问题,还是VScode的问题hhhh 参考该链接: https://blog.csdn.net/LOVEmy134611/article/details/107212845 把QT的flag打开,我们才能看到报错的详细信息 注意,这个执行后,该环境变

    2024年02月09日
    浏览(37)
  • qt.qpa.plugin: Could not find the Qt platform plugin “windows“ in ““

    使用nuitka打包pyqt5后,运行exe时报错 报错如下: 原因分析 这是由于打包后,pyqt5无法找到插件plugin 导致的。 解决方法 1、先找到虚拟环境中的Pyqt5,比如我的: 2、把Qt5文件夹复制到打包好后的PyQt5文件夹中 亲测有效,如果能够解决你遇到的问题,请帮忙点个赞,顺便收藏下

    2024年02月15日
    浏览(48)
  • qt.qpa.plugin: could not load the qt platform plugin “windows“ in ““ even though it was found.

    今天在PyTorch 神经网络学习时,执行代码出现如下 错误: qt.qpa.plugin: could not load the qt platform plugin \\\"windows\\\" 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: minimal, offscreen, web

    2024年02月14日
    浏览(37)
  • Ubuntu 20.04下安装配置Qt开发环境的步骤

    下面是在Ubuntu 20.04下安装配置Qt开发环境的步骤: 安装Qt Creator 在终端中输入以下命令以安装Qt Creator: 在终端中输入以下命令以安装Qt 5开发库: 安装g++和gcc编译工具 配置Qt Creator 打开Qt Creator,进入“Tools”菜单,选择“Options”,在弹出的对话框中选择“Build Run”,然后选择

    2024年02月15日
    浏览(43)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包