2

ubuntu 18.04 解决 PyQt5 无法加载 xcb 插件问题

 1 year ago
source link: https://xugaoxiang.com/2022/12/06/ubuntu-pyqt5-load-xcb/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
  • ubuntu 18.04 64bit
  • anaconda with python 3.7
  • pyqt5 5.15

使用 conda 创建了全新的虚拟环境

conda create -n test python=3.7

然后使用 pip 安装 pyqt5

pip install pyqt5

但是在使用 pyqt5 的过程中就会报错,如下

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" 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: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

Aborted (core dumped)

大意是加载不了插件 xcb,虽然已经发现了这个插件。

为了得到更多的调试信息,我们使用了一个环境变量

export QT_DEBUG_PLUGINS=1

然后重新跑一下原来的代码,就可以发现更多的信息

e8921caf3d4131ab.png

可以看到,在加载 libqxcb.so 时,还依赖于 libxcb-xinerama.so

那就安装一下

sudo apt-get install libxcb-xinerama0

最后再跑一下之前的代码,报错就没有了

至此问题解决。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK