问题描述:

见下图:

import matplotlib.pyplot as plt
import cv2
img=cv2.imread('img_path')###读入单张图片b,g,r=cv2.split(img) #原图的bgr三个通道分离
img_rgb=cv2.merge([r,g,b])#rgb顺序显示的合成plt.figure()
plt.subplot(331),plt.imshow(img),plt.title("cat_bgr")plt.subplot(337),plt.imshow(img_rgb),plt.title("cat_rgb")plt.show()

运行如上代码,博主要调用matplotlib函数绘图,在网上搜索*“This application failed to start because it could not find or load the Qt platform plugin “xcb”*,得到以下解决方案:

方法一:

原因分析:
matplotlib版本不兼容

解决思路:
先卸载原有matplotlib再重新安装

参考:

pip uninstall matplotlib
pip install matplotlib

方法二:

原因分析:

我们是要调用matplotlib函数绘图,而报错提示it could not find or load the Qt platform plugin “xcb” in " "
所以考虑Qt和matplotlib版本不兼容导致

解决思路:
卸载了QT与matplotlib并重新安装

参考:

conda uninstall qt
conda uninstall matplotlib
conda install qt
conda install matplotlib

方法三:

原因分析:
platforms文件夹内缺少相应的文件,尝试自己进行手动切换,对Qt安装目录下的查找platforms文件,是plugins文件下的一个子文件,将其中的.dll文件放到自己的文件夹下,即可运行。

此种方案博主没有尝试,因为涉及到底层依赖文件的移动,很容易因为漏掉某些文件出现问题,而且因为当时conda环境比较乱,找不到Qt的安装目录,于是放弃这种方案,不推荐尝试采用

方法四(可能是最常见的一种情况):

前提条件:
命令行输入qtcreator产生报错:

This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.Reinstalling the application may fix this problem.
Aborted (core dumped)

如果使用qtcreator可以正常启动,则不属于这种情况,正常启动如下图:

解决方法:
1.输入

sudo gedit ~/.bashrc

在最后一行添加:

export QT_DEBUG_PLUGINS=1

这一步的作用是可以在qt启动过程中看到报错信息
2.运行qtcreator,在命令行得到运行中过程,如下:

Got keys from plugin meta data ("vnc")
QFactoryLoader::QFactoryLoader() looking at "/opt/Qt5.10.0/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so"
Found metadata in lib /opt/Qt5.10.0/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so, metadata=
{"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3","MetaData": {"Keys": ["xcb"]},"className": "QXcbIntegrationPlugin","debug": false,"version": 330240
}Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/opt/Qt5.10.0/Tools/QtCreator/bin/platforms" ...
Cannot load library /opt/Qt5.10.0/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so: (/usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5: version `Qt_5_PRIVATE_API' not found (required by /opt/Qt5.10.0/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so))
QLibraryPrivate::loadPlugin failed on "/opt/Qt5.10.0/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so" : "Cannot load library /opt/Qt5.10.0/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so: (/usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5: version `Qt_5_PRIVATE_API' not found (required by /opt/Qt5.10.0/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so))"
This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.Reinstalling the application may fix this problem.
Aborted (core dumped)

3.原因在于libqxcb.so,cd到/opt/Qt5.10.0/5.10.0/gcc_64/plugins/platforms,运行命令ldd libqxcb.so,查看关联内容,如下:

./libqxcb.so: /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5: version `Qt_5_PRIVATE_API' not found (required by ./libqxcb.so)
./libqxcb.so: /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5: version `Qt_5_PRIVATE_API' not found (required by ./libqxcb.so)
./libqxcb.so: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.10' not found (required by ./libqxcb.so)
./libqxcb.so: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5' not found (required by ./libqxcb.so)

可以看到问题在于:‘Qt_5_PRIVATE_API’ not found
4.需要添加环境变量,如下:

export LD_LIBRARY_PATH=/opt/Qt5.10.0/5.10.0/gcc_64/lib:$LD_LIBRARY_PATH

5.命令行输入qtcreator,成功运行

方法五:

思路一:
设置环境变量 export QT_DEBUG_PLUGINS=1

运行看到QT程序加载的过程,看到了详细的报错信息。
最后一部分是这样的:

Found metadata in lib /usr/lib64/qt5/plugins/platforms/libqxcb.so, metadata=
{"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3","MetaData": {"Keys": ["xcb"]},"className": "QXcbIntegrationPlugin","debug": false,"version": 329218
}
QLibraryPrivate::loadPlugin failed on "/usr/lib64/qt5/plugins/platforms/libqxcb.so" : "Cannot load library /usr/lib64/qt5/plugins/platforms/libqxcb.so: (/lib64/libQt5XcbQpa.so.5: symbol _ZNK11QFontEngine6handleEv, version Qt_5_PRIVATE_API not defined in file libQt5Gui.so.5 with link time reference)"
This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, xcb, xcb.Reinstalling the application may fix this problem.

把libQt5XcbQpa.so,libQt5DBus.so.5拷贝到运行目录。

思路二:
将qt下plugins目录下的platforms目录拷贝到可执行目录,和执行程序同一级目录(一定同一级)

这种方法同方法三

方法六:

解决qt.qpa.plugin: Could not find the Qt platform plugin “xcb“ in ““

方法七(也是我最后的解决方法):

思路:
重新创建一个conda环境:

conda create -n env_name python=3.7

安装matplotlib包:

pip install matplotlib

成功解决!

参考链接:
1.[SOLVED] qt.qpa.plugin: Could not find the Qt platform plugin “xcb” in “”

【Ubuntu】QT程序 could not find or load the Qt platform plugin “xcb“ in “报错解决相关推荐

  1. 解决Ubuntu系统安装QT出错的问题:qt.qpa.plugin: Could not load the Qt platform plugin “xcb“ in ““ even though it

    最近新入手的笔记本无法安装Ubuntu系统,无奈只能通过VirtualBox安装Ubuntu16.04,但是发现安装最新版本的QT5.12.10时候无法启动QtCreator程序,通过命令行运行发现如 ...

  2. 【Qt】Qt发布程序时,报错: could not find or load the Qt platform plugin xcb

    问题描述 Qt程序在发布时,报错: This application failed to start because it could not find or load the Qt platform ...

  3. Linux下解决发布Qt程序报错:it could not find or load the Qt platform plugin “xcb” in “”

    简述 用Qt5.8版本在ubuntu16.04版本下编写Qt应用程序,生成release版本并打包,到另一台无Qt环境的linux系统中运行. 网上通常是按以下几个步骤进行: 1.生成release程 ...

  4. Ubuntu16.04下Python程序出现错误qt.qpa.plugin: Could not load the Qt platform plugin xcb解决方法

    问题描述 我在运行一个使用Pyqt5库的Python程序时,出现报错: qt.qpa.plugin: Could not load the Qt platform plugin "xcb&q ...

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

    在ubuntu上使用qt出现报错:qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" ...

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

    Ubuntu18.04下解决Qt出现qt.qpa.plugin:Could not load the Qt platform plugin "xcb"问题 问题描述 定位问题 解决 ...

  7. uBuntu20.04安装Qt5.15.2出现qt.qpa.plugin: Could not load the Qt platform plugin “xcb“的问题解决

    由于Qt6.22太新,我不得不重新安装了Qt,同时安装了Qt6.22和Qt5.15.2,安装完毕后使用Qt6.22是没有问题的,但使用Qt5.15.2运行程序时,提示如下错误 qt.qpa.plugi ...

  8. 出现“qt.qpa.plugin: Could not load the Qt platform plugin “xcb“ in ‘ ’even though it was found

    出现"qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in ' 'even though it wa ...

  9. 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 & ...

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

    1.问题描述 在ubuntu18.04中第一次安装QT5,运行时报错 qtcreator.sh qt.qpa.plugin: Could not load the Qt platform plugin ...

最新文章

  1. SQL Server 执行计划
  2. 成功解决Fit Failed Warning: Estimator fit failed. The score on this train-test partition for these param
  3. linux atom 升级,Github更新Atom,主要集中在Windows
  4. 《赛博朋克 2077》与《对马岛之魂》的「不自由感」究竟从何而来?
  5. Spring中Bean的生命周期是怎样的?
  6. Liunx 命令大全
  7. MySQL 数据库 like 语句通配符模糊查询小结
  8. tab切换webuploader失效的解决方法
  9. linux grep 日期,linux 文本处理工具之一grep命令详解
  10. C# 使用Magick.NET进行图片格式转换,修改尺寸(.ico .jpg .png .gif .bmp),解决png转jpg透明变黑底问题
  11. glassfish java环境_GlassFish安装和配置详解
  12. 云计算中的laaS、PaaS和SaaS是什么意思?
  13. vue3 ts版本深度拷贝功能推荐ts-deepmerge
  14. 年轻代和老年代垃圾回收
  15. 讯捷CAD编辑器一秒解决CAD制图怎么画直线
  16. 在Win7中设置PPT放映时显示备注
  17. android高德地图计算行驶里程,高德地图批量统计驾车轨迹的用时及总里程
  18. C++11 文件读写(vs2019 安装配置boost库)
  19. 2021完整版:Kubernetes Deployment故障排除的可视化指南
  20. 珠宝erp是否能带回珠宝行业的“黄金时代”?

热门文章

  1. 为泄愤程序员攻击北京摇号网站昨受审 曾为市高考状元
  2. 从Altium官方网站下载库文件
  3. 11_JavaWeb三大组件之Filter拦截器与Listener监听器
  4. 全国社会组织信用信息公式平台(试运行)爬虫记录
  5. VIM复制粘贴 的快捷键是什么
  6. 什么是Promise?Promise有什么好处
  7. JS代码错误:Deleting local variable in strict mode
  8. Android安全之使用root权限绕过检测机制,强行自动允许应用的悬浮窗/应用后台弹出界面等权限
  9. matlab的基本函数,matlab基本函数
  10. svg 树状图_树状图(关系图)