Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] qt.qpa.plugin: Could not load the Qt platform plugin "xcb" -- fixed #842

Closed
fatalfeel opened this issue Mar 8, 2021 · 16 comments
Closed
Labels
bug issue

Comments

@fatalfeel
Copy link

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/usr/lib/python3.7/site-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl.

//////////////////////or//////////////////////////////////
QObject::moveToThread: Current thread (0xe38c70) is not the object's thread (0x1ab6aa0).
Cannot move to target thread (0xe38c70)

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/usr/lib/python3.7/site-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

///////////////////trace bug method
ldd /usr/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so
search [not found]

/////////////////// solved//////////////
sudo apt-get install python3-pyqt5
sudo apt-get install libxcb-xinerama0
sudo pip3 install pyqt5
sudo pip3 install opencv-python==3.4.10.35
sudo pip3 install labelme

@fatalfeel fatalfeel added the bug issue label Mar 8, 2021
@Heermosi
Copy link

I'm faced with the same , ... so called bugs? It was some thing relative to qt in Linux, may be you should submit the bug to opencv.
No not at all, you do not need anything else to make it work, just remove the damn

/usr/lib/python3.7/site-packages/cv2/qt/plugins
then everything is fine....
May be the plugin shipped with opencv was not suited for this version of QT.
And it was a particular problem when opencv and pyqt installed at the same time in Linux. No such issue detected in Windows.

@TaucherLoong
Copy link

I have the same problem for a week, you mean 'remove /usr/lib/python3.7/site-packages/cv2/qt/plugins'. How to remove? remove the whole plugins directory or all files under this directory

@TaucherLoong
Copy link

or remove the qt directory?

@YacobBY
Copy link

YacobBY commented Jul 10, 2021

@TaucherLoong Delete the whole plugins directory from wherever your venv is located. In my Project using the Pycharm IDE this would be venv/lib/python3.9/site-packages/cv2/qt/plugins
Screenshot from 2021-07-10 14-37-51

@TaucherLoong
Copy link

TaucherLoong commented Jul 12, 2021

@YacobBY Thanks a lot,it really works

@wkentaro
Copy link
Owner

Thanks for finding and sharing the solution. 👍

@fsevenm
Copy link

fsevenm commented Dec 27, 2021

I'm faced with the same , ... so called bugs? It was some thing relative to qt in Linux, may be you should submit the bug to opencv. No not at all, you do not need anything else to make it work, just remove the damn

/usr/lib/python3.7/site-packages/cv2/qt/plugins then everything is fine.... May be the plugin shipped with opencv was not suited for this version of QT. And it was a particular problem when opencv and pyqt installed at the same time in Linux. No such issue detected in Windows.

In my case Ubuntu 21.04, it's in /usr/local/lib/python3.9/dist-packages/cv2/qt/plugins. And yes, removing them or moving to other folder fixed the issue.

@JPLeoRX
Copy link

JPLeoRX commented Apr 25, 2022

Dialing in here - removing the whole plugins folder breaks opencv if you're using it in normal (not headless) mode. I feel like this bug needs a better solution.

@nick-halden
Copy link

nick-halden commented Jun 23, 2022

In case you're running on a server: Check if there are any calls for graphical output like cv2.namedWindow, cv2.imshow(), ...
If so, delete them.

@trezero
Copy link

trezero commented Sep 29, 2022

What if I want the graphical output? Is there no way to have it work with the windows? It will be really hard to know if the app is working without being able to see anything for testing

@AbdelsalamHaa
Copy link

Thanks @TaucherLoong ,
your solution worked for me :)

@Airluv
Copy link

Airluv commented Jul 12, 2023

@TaucherLoong Delete the whole plugins directory from wherever your venv is located. In my Project using the Pycharm IDE this would be venv/lib/python3.9/site-packages/cv2/qt/plugins Screenshot from 2021-07-10 14-37-51

It really works!!!

@MarwanMagdy0
Copy link

the solution works for me but when i use the normal opencv imshow function it shows this error
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in "/home/marwan/.local/lib/python3.8/site-packages/cv2/qt/plugins"
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Aborted (core dumped)

@lixiang0
Copy link

L solved it by the blow command:

pip uninstall opencv-python
pip install opencv-python-headless

@tsrobcvai
Copy link

I solved this by installing a lower version of pyqt5

pip uninstall pyqt5
pip install pyqt5==5.10

@BoZhiStudying233
Copy link

Thanks for the solution, it worked for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issue
Projects
None yet
Development

No branches or pull requests