欢迎访问我的网站,希望内容对您有用,感兴趣的可以加入免费知识星球。

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

Linux 迷途小书童 1年前 (2022-12-06) 173490次浏览 0个评论

环境

  • 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

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

ubuntu pyqt5

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

那就安装一下

sudo apt-get install libxcb-xinerama0

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

至此问题解决。

参考资料

喜欢 (1)

您必须 登录 才能发表评论!