qt.qpa.plugin:无法加载Qt平台插件"xcb",无法初始化Qt平台,但"Available platform plugins are: xcb, eglfs......"



我正在尝试使用Qt和opencv运行一个创建UI的脚本。然而,这是一个奇怪的错误,我得到

python3 dashboard.py 
QObject::moveToThread: Current thread (0xaffdf0) is not the object's thread (0x552f790).
Cannot move to target thread (0xaffdf0)
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/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.
Aborted (core dumped)

这是ldd-ing libqxcb.so 的输出

ldd libqxcb.so 
linux-vdso.so.1 (0x00007ffdbfbf5000)
libQt5XcbQpa-ca221f44.so.5.15.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libQt5XcbQpa-ca221f44.so.5.15.0 (0x00007f32102a5000)
libfreetype-c0e61f0c.so.6.14.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libfreetype-c0e61f0c.so.6.14.0 (0x00007f320ffd9000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f320ffa9000)
libQt5Gui-ba0a2070.so.5.15.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libQt5Gui-ba0a2070.so.5.15.0 (0x00007f320f6a1000)
libQt5Core-39545cc7.so.5.15.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libQt5Core-39545cc7.so.5.15.0 (0x00007f320ef9c000)
libGL.so.1 => /lib/x86_64-linux-gnu/libGL.so.1 (0x00007f320ef14000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f320eef2000)
libX11-xcb-69166bdf.so.1.0.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libX11-xcb-69166bdf.so.1.0.0 (0x00007f320ecef000)
libxcb-icccm-413c9f41.so.4.0.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libxcb-icccm-413c9f41.so.4.0.0 (0x00007f320eae9000)
libxcb-image-e82a276d.so.0.0.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libxcb-image-e82a276d.so.0.0.0 (0x00007f320e8df000)
libxcb-shm-7a199f70.so.0.0.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libxcb-shm-7a199f70.so.0.0.0 (0x00007f320e6d9000)
libxcb-keysyms-21015570.so.1.0.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libxcb-keysyms-21015570.so.1.0.0 (0x00007f320e4d5000)
libxcb-randr-a96a5a87.so.0.1.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libxcb-randr-a96a5a87.so.0.1.0 (0x00007f320e2be000)
libxcb-render-util-43ce00f5.so.0.0.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libxcb-render-util-43ce00f5.so.0.0.0 (0x00007f320e0b8000)
libxcb-render-637b984a.so.0.0.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libxcb-render-637b984a.so.0.0.0 (0x00007f320dea2000)
libxcb-shape-25c2b258.so.0.0.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libxcb-shape-25c2b258.so.0.0.0 (0x00007f320dc9c000)
libxcb-sync-89374f40.so.1.0.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libxcb-sync-89374f40.so.1.0.0 (0x00007f320da93000)
libxcb-xfixes-9be3ba6f.so.0.0.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libxcb-xfixes-9be3ba6f.so.0.0.0 (0x00007f320d887000)
libxcb-xinerama-ae147f87.so.0.0.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libxcb-xinerama-ae147f87.so.0.0.0 (0x00007f320d682000)
libxcb-xkb-9ba31ab3.so.1.0.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libxcb-xkb-9ba31ab3.so.1.0.0 (0x00007f320d459000)
libxcb.so.1 => /lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f320d42f000)
libXext.so.6 => /lib/x86_64-linux-gnu/libXext.so.6 (0x00007f320d41a000)
libX11.so.6 => /lib/x86_64-linux-gnu/libX11.so.6 (0x00007f320d2dc000)
libSM.so.6 => /lib/x86_64-linux-gnu/libSM.so.6 (0x00007f320d2d1000)
libICE.so.6 => /lib/x86_64-linux-gnu/libICE.so.6 (0x00007f320d2b4000)
libxkbcommon-x11-c65ed502.so.0.0.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libxkbcommon-x11-c65ed502.so.0.0.0 (0x00007f320d0a5000)
libxkbcommon-71ae2972.so.0.0.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libxkbcommon-71ae2972.so.0.0.0 (0x00007f320ce64000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f320ce5d000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f320cc44000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f320caf6000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f320cadb000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f320c8ed000)
libgthread-2.0.so.0 => /lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f320c8e8000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f320c7b2000)
libbz2-a273e504.so.1.0.6 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libbz2-a273e504.so.1.0.6 (0x00007f320c5a1000)
libpng15-ce838cd1.so.15.13.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libpng15-ce838cd1.so.15.13.0 (0x00007f320c374000)
/lib64/ld-linux-x86-64.so.2 (0x00007f3210533000)
libGLdispatch.so.0 => /lib/x86_64-linux-gnu/libGLdispatch.so.0 (0x00007f320c2ba000)
libGLX.so.0 => /lib/x86_64-linux-gnu/libGLX.so.0 (0x00007f320c286000)
libxcb-util-4d666913.so.1.0.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libxcb-util-4d666913.so.1.0.0 (0x00007f320c07f000)
libXau-00ec42fe.so.6.0.0 => /home/aevas/Desktop/pyenvs/newpy39/lib/python3.9/site-packages/cv2/qt/plugins/platforms/./../../../../opencv_python.libs/libXau-00ec42fe.so.6.0.0 (0x00007f320be7a000)
libXau.so.6 => /lib/x86_64-linux-gnu/libXau.so.6 (0x00007f320be72000)
libXdmcp.so.6 => /lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f320be6a000)
libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f320be61000)
libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f320be49000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f320bdd3000)
libmd.so.0 => /lib/x86_64-linux-gnu/libmd.so.0 (0x00007f320bdc4000)

pip列表,只获取opencv和qt内容

opencv-python           4.5.5.62
PyQt5                   5.15.6
PyQt5-Qt5               5.15.2
PyQt5-sip               12.9.1

我也查阅了这些链接,但没有用:

  1. https://github.com/Yuliang-Liu/Curve-Text-Detector/issues/11

  2. https://forum.qt.io/topic/93247/qt-qpa-plugin-could-not-load-the-qt-platform-plugin-xcb-in-even-though-it-was-found/65(已经完成了所有的sudo apt-get安装(

  3. https://unix.stackexchange.com/questions/338519/how-to-install-libxcb(我也执行了所需的sudo apt-get安装(

  4. 如何修复错误";QObject::moveToThread:";在python中的opencv中?(pip不允许我安装旧版本的opencv-python(

  5. https://www.programmersought.com/article/20797211182/(也关于降级opencv,我无法(

  6. 删除";qt";文件夹;cv2";从python站点软件包进行安装似乎可以使其正常工作。然而,这会破坏其他依赖opencv_python的东西。

我只是安装了旧版本opencv-python==4.3.06。按用途:

pip uninstall opencv-python
pip install opencv-python==4.3.06

之后。qt错误消失。

如果你不能用pip卸载。你会用conda安装cv吗?

这是我找到的唯一可行的解决方案:

pip install pyqt5==5.14.2 opencv-python==4.8.0.76

5.14.2以上版本的pyqt5导致了原始问题中的错误。

相关内容

  • 没有找到相关文章

最新更新