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
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值