在使用python3.7+pycharm+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)
在网上找了很多解决方法,最终参照这篇博客解决问题:链接: 解决方法.
具体操作如下:
1.修改配置文件:
sudo gedit ~/.bashrc
2.在最末尾添加如下语句并保存,在运行测试用例的时候会列出详细的错误提示:
export QT_DEBUG_PLUGINS=1
3.最终发现是Qt动态链接库的问题,错误提示不存在libxcb-xinerama.so.0库。安装libxcb-xinerama库:
#如果还存在其他依赖库没有安装,也一并安装。
$ sudo apt-get install libxcb-xinerama0
4.再次运行测试用例,可以成功打开qt。