问题描述:

见下图:

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. 郭振宇计算机领域,数学实验教学中心简介
  2. 在数据库创建表的时候,时间设置为什么类型,会随着每次提交的时间发生变化
  3. linux shell sed 删除文件 前几行
  4. 使用flexible适配移动端h5页面
  5. 分类图 Class Diagram
  6. 文件用户如何将一个有界面的正常app和一个或多个越狱插件.deb同时安装到手机上...
  7. 更新两个WPF开源项目
  8. linux 启动db2 服务器,Linux系统设置DB2等服务开机启动的过程
  9. 访问者(Visitor Pattern )模式
  10. 解决VMWare Workstation 响应慢
  11. C语言26L,LNBH26L - 双路LNBS电源和控制IC,带升压和I²C接口 - STMicroelectronics
  12. dede php判断,织梦视频页面用PHP判断用户访问类型
  13. mmWave AWR1x Interference Detection - A crucial step to effective mitigation
  14. ORA-01033错误解决方法
  15. python 快乐的数字
  16. “数据”企业之命脉,守护有责。
  17. Java Game Resource
  18. 几种方法判断平面点在三角形内
  19. API调用,淘宝天猫、1688、京东、拼多多商品页面APP端原数据获取
  20. SSIS - 1.简介

热门文章

  1. 计算机音乐多幸运,多幸运(伴奏) 韩安旭 多幸运(伴奏)歌曲,多幸运(伴奏)mp3在线试听 - 5nd音乐网...
  2. 元子弹老师-吉他指弹泛音
  3. latex 上标 下标怎么打
  4. android网络连接的判断
  5. Mybatis框架与mysql数据库简单应用
  6. python搜索引擎的设计与实现_Python搜索引擎实现原理和方法
  7. monthcalendar控件
  8. 爱情树代码python_送男朋友礼物送什么比较有意义?
  9. WIN10系统安装虚拟机以及CentOS7
  10. 人物-IT-史玉柱:史玉柱