Could not find or load the Qt platform plugin "xcb"
Solution 1
Same problem with Linux Mint 17, 64 bit. It was solved after 4h searching on the net! You need to give these commands on the terminal from folder /anaconda2/bin
sudo ./conda remove qt
sudo ./conda remove pyqt
sudo ./conda install qt
sudo ./conda install pyqt
Hope it helps!
Solution 2
To fix this problem, I added to the top:
import matplotlib
matplotlib.use('Agg')
I have a CentOS7, Anaconda3-4.5.0, python3.5 pyqt version 5.6.0 and qt version 5.6.0
If you want to use the plot in a Tkinter window for visualisation then use:
matplotlib.use('TkAgg')
Solution 3
I experienced this problem on Ubuntu 16.04 with anaconda 4.3.17 (Python 2.7). The issue stemmed from anaconda having Qt version 5.6 installed, while my system Qt libraries were at version 5.5.
A quick hack is to make sure Anaconda libraries precede your system libraries by setting LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=$HOME/anaconda2/lib:$LD_LIBRARY_PATH
Unfortunately, this will break other programs that use Qt 5.5, so you can only use it in situations that are 100% anaconda python, for example, if you're starting an ipython session with --pylab.
I discovered that this was the issue by looking at the way libxqcb.so was linked:
ldd $HOME/anaconda2/plugins/platforms/libqxcb.so
which reported the following errors:
./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' 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)
./libqxcb.so: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.6' not found (required by ./libqxcb.so)
The error messages are saying they can't find Qt_5.6, which is anaconda's version. The version on my system was 5.5, which I found out by looking at the filenames that resulted from this command:
ls /usr/lib/x86_64-linux-gnu/libQt*
Solution 4
This can also happen when using something like an ssh session to connect to for instance a piece of software that is using X11 graphical libraries as I recently discovered.
The issue occurs when trying to plot images in the graphical user interface, using:
cv2.imshow()
or
plot.show()
In this case you should either use ssh -XY or you should consider saving to a file instead such as
cv2.imwrite('file.png')
or
plt.savefig('file.png')
I had this problem when using a deep neural network that was originally geared towards being used in conjunction with Jupyter notebook. When writing the images to files instead of displays, the code the ran through multiple ssh tunnels without reporting the xcb and Qt bug.
By the way, it didn't matter what variant of Qt4 or Qt5 was installed. It still failed with the same error message.
Solution 5
I had to upgrade several python packages to make it work. In particular:
pip3 install --upgrade pyside2 pyqt5
Yantao Xie
Interesting on Face Recognition, Gesture Recognition and 3D Reconstruction. Programming on Linux for Android and iOS.
Updated on July 05, 2020Comments
-
Yantao Xie almost 4 years
On my OS(Linux Mint Debian Edition 2), except for the system python(/usr/bin/python) installed by the apt, I also installed the anaconda. But I've encounterd a problem running the following code with the anaconda python
# test.py import matplotlib.pyplot as plt import numpy as np x = np.array([0, 1]) plt.scatter(x, x) plt.show()
The error is
This application failed to start because it could not find or load the Qt platform plugin "xcb".
Reinstalling the application may fix this problem.
Aborted
But if I try with the system python, i.e.,
/usr/bin/python test.py
, it works correctly.Then I tried the ipythons, of system and of anaconda, the result is same as before: the anaconda ipython kernel died.
And I tried add the ipython magic
%matplotlib inline
into the code, the anaconda ipython works correctly now. But if I replace the%matplotlib inline
with%pylab
, the anaconda ipython died again.Note: I use the python 2.7. System ipython's version is 2.3, anaconda ipython's version is 3.2.