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

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.

猜你喜欢

转载自blog.csdn.net/jiaken2660/article/details/106517937
今日推荐