This application failed to start because it could not find or load the Qt platform plugin xcb

14 篇文章 0 订阅
14 篇文章 0 订阅

1.Background:

I download labelImg from github(labelImg), and want to modify the source code to add my special functionnalities. And I configure the PyQt5 according to the mannul  as follows:

first: open anaconda and cd to the labelImg folder

second:type in follows command

sudo apt-get install pyqt5-dev-tools
sudo pip3 install -r requirements/requirements-linux-python3.txt
make qt5py3
python3 labelImg.py
python3 labelImg.py [IMAGE_PATH] [PRE-DEFINED CLASS FILE]

when I run the "python3 labelImg.py", I encounter this error:

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.

My enviroment is:Ubuntu16.04, Anaconda 3, python3.7, I googled all the network, and try many methods, it doesn't work for me. And at last, I solved the error through following steps:

2.Solutions

2.1 Enable the Qt plugin debug information to get hidden hint

sudo gedit ~/.bashrc

add follows sentence to the end:

export QT_DEBUG_PLUGINS=1

then

source ~/.bashrc

2.2 Run the python labelImg.py again

I got follows information:

Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/home/jiaken2660/anaconda3/bin/platforms" ...
Cannot load library /home/jiaken2660/anaconda3/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so: (/home/jiaken2660/Qt5.9.9/5.9.9/gcc_64/lib/libQt5XcbQpa.so.5: symbol _ZNK15QPlatformWindow15safeAreaMarginsEv, version Qt_5_PRIVATE_API not defined in file libQt5Gui.so.5 with link time reference)
QLibraryPrivate::loadPlugin failed on "/home/jiaken2660/anaconda3/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so" : "Cannot load library /home/jiaken2660/anaconda3/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so: (/home/jiaken2660/Qt5.9.9/5.9.9/gcc_64/lib/libQt5XcbQpa.so.5: symbol _ZNK15QPlatformWindow15safeAreaMarginsEv, 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, vnc, xcb.

because my python path is:

/home/jiaken2660/anaconda3/bin/python

you can see libqxcb.so calls the "/home/jiaken2660/Qt5.9.9/5.9.9/gcc_64/lib/libQt5XcbQpa.so.5" which mismatched in my computer. The former is a version which installed before for QtCtreator, and the truely matched libQt5XcbQpa.so.5 is under follows folder, and should match the PyQt5 library.

/home/jiaken2660/anaconda3/lib/python3.7/site-packages/PyQt5/Qt/lib/libQt5XcbQpa.so.5

So, modify ~/.bashrc file

export LD_LIBRARY_PATH=/home/jiaken2660/anaconda3/envs/PyQt5/lib/python3.7/site-packages/PyQt5/Qt/lib:$LD_LIBRARY_PATH

and add the plugin enviroment variable.

export QT_PLUGIN_PATH=/home/jiaken2660/anaconda3/lib/python3.7/site-packages/PyQt5/Qt/plugins

After this, the qt plugin matched the qt library,such as libQtCore, libQtGui etc. But I get another error, please see below:

Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/home/jiaken2660/anaconda3/bin/platforms" ...
Cannot load library /home/jiaken2660/anaconda3/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so: (/home/jiaken2660/anaconda3/lib/python3.7/site-packages/PyQt5/Qt/lib/libQt5Core.so.5: version `Qt_5.15' not found (required by /home/jiaken2660/anaconda3/envs/PyQt5/lib/python3.7/site-packages/PyQt5/Qt/lib/libQt5XcbQpa.so.5))
QLibraryPrivate::loadPlugin failed on "/home/jiaken2660/anaconda3/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so" : "Cannot load library /home/jiaken2660/anaconda3/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so: (/home/jiaken2660/anaconda3/lib/python3.7/site-packages/PyQt5/Qt/lib/libQt5Core.so.5: version `Qt_5.15' not found (required by /home/jiaken2660/anaconda3/envs/PyQt5/lib/python3.7/site-packages/PyQt5/Qt/lib/libQt5XcbQpa.so.5))"
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.

the error is:version `Qt_5.15' not found, beacuse the PyQt5 installed is 5.9.2, so just reinstall the PyQt5:

pip install PyQt5==5.15.0

then all the errors gone. disable the QT_DEBUG_PLUGINS=1 at last. That's it. unfortunately, I spent one day to get it work.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据提供的引用内容,当应用程序无法找到或加载Qt平台插件时,会出现"This application failed to start because it could not find or load the Qt platform plugin"的错误消息。这个问题通常是由于缺少Qt平台插件或者插件无法正确初始化导致的。 解决这个问题的方法有以下几种: 1. 确保正确安装了Qt框架:首先,确保你已经正确地安装了Qt框架。如果没有安装,可以从Qt官方网站下载并安装最新版本的Qt。 2. 检查环境变量:确保环境变量中包含了Qt的安装路径。在Windows系统中,可以在系统的环境变量中添加Qt的安装路径。在Linux系统中,可以在.bashrc或者.profile文件中添加Qt的安装路径。 3. 检查Qt平台插件:确保Qt的平台插件正确安装并可用。在Qt的安装目录下,可以找到plugins文件夹,其中包含了各种平台插件。确保这些插件文件存在且完整。 4. 检查应用程序依赖:应用程序可能依赖于其他库或者插件。确保这些依赖项正确安装并可用。 5. 重新安装应用程序:如果以上方法都无法解决问题,可以尝试重新安装应用程序。有时候,重新安装可以修复一些问题。 下面是一个示例代码,演示了如何处理Qt平台插件问题: ```python import sys from PyQt5.QtWidgets import QApplication, QMainWindow if __name__ == "__main__": app = QApplication(sys.argv) try: # 创建主窗口 mainWindow = QMainWindow() mainWindow.show() sys.exit(app.exec_()) except Exception as e: print("Error: ", str(e)) ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值