Ubuntu20.04在Pycharm运行时出现Could not load the Qt platform plugin "xcb"问题
用mmclassification跑test.py脚本,绘制预测图时出现以下问题:
qt.qpa.plugin: Could not load the Qt platform plugin “xcb” in “/home/taoyang/Software/anaconda3/envs/py37/lib/python3.7/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, minimal, minimalegl, offscreen, vnc, webgl.
解决方法如下:
在文件开头输入如下代码,其中的路径为报错代码中的路径后再加一个/platforms
envpath = '/home/taoyang/Software/anaconda3/envs/py37/lib/python3.7/site-packages/cv2/qt/plugins/platforms'
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = envpath
但是有点治标不治本,后面在运行labelme时又会报错,卸载QT5也没用,经过一番寻找终于找到解决方案,就是降低opencv版本:
pip install opencv-python==4.1.2.30
————————————————
版权声明:本文为CSDN博主「carambola_TaoYang」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/carambola_/article/details/127176223
另一种方法:
一般出现qt.qpa.plugin: Could not load the @t platform plugin "xcb"in问题,主要是安装pyt5后,缺少一些链接库,通过以下方法定位到缺少哪个链接库
。在环境中 export QT DEBUG PLUGINS=1
。执行出现该问题到程序,便可以定位到缺失的链接库。
在ubuntu系统中一般是libxcb-xinerama.so.0,通过sudo apt-get install libxcb-xinerama0
在centos系统中一般是ibxkbcommon-x11.so.0,通过yum install libxkbcommon-x11-devel
提供两个通过文件名查找包名到网站
http://rpm.pbone.net
http://rpmfind.net
参考:qt.qpa.plugin: Could not load the Qt platform plugin “xcb“ in问题_ustczhng2012的博客-CSDN博客
Ubuntu18.04下解决Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“问题_Linux_脚本之家