解决qt.qpa.plugin: Could not load the Qt platform plugin “xcb“问题

问题一

运行程序,报错qt.qpa.plugin: Could not load the Qt platform plugin “xcb” 定位后是pyqt5问题,什么修改动态连接文件、降低版本,各种方式都试过了都不能解决,使用conda安装后启动正常。

QObject::moveToThread: Current thread (0x557d2ffe4400) is not the object's thread (0x557d30751de0).
Cannot move to target thread (0x557d2ffe4400)

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/cv/anaconda3/envs/darknet/lib/python3.6/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.

已放弃 (核心已转储)

pip卸载原有的pyqt5,使用conda install 安装

pip uninstall pyqt5
conda install pyqt

问题二

安装Qtpy后运行程序报错,经过反复查找资料调试后还是不能运行,最后发现是版本不匹配问题。

(darknet) cv@cv-System-Product-Name:~/wankou_detect_5_6_batch4$ python script.py 
Traceback (most recent call last):
  File "script.py", line 1, in <module>
    from PyQt5 import QtWidgets
ImportError: /home/cv/anaconda3/lib/libQt5Core.so.5: version `Qt_5.12' not found (required by /home/cv/anaconda3/envs/darknet/lib/python3.8/site-packages/PyQt5/QtWidgets.so)

卸载掉之前的版本,或者直接安装就可以,安装适配的版本后成功运行,折腾了一上午,什么更改环境变量,什么方法都使了都不好用,最后重新装了pyqt5==5.12好用了。

pip install pyqt5==5.12

你可能感兴趣的:(python,linux,qt,python,开发语言)