Could not load the Qt platform plugin “xcb“ in

在Linux上用Vscode调试MAPPO代码时碰到“Could not load the Qt platform plugin “xcb” in…”问题,问题详细描述如下:

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/cloris/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, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl.

报错原图:
网上查找解决方法如下:
在终端输入如下代码:

export QT_QPA_PLATFORM=offscreen

成功解决问题

上面适用 没有显示器的时候,如果有显示器,设置成offscreen会报下面的错误:

X Error of failed request: BadWindow (invalid Window parameter) Major opcode of failed request: 3 (X_GetWindowAttributes) Resource id in failed request: 0x4 Serial number of failed request: 7 Current serial number in output stream: 8

这时候只需要把参数设置成 

export QT_QPA_PLATFORM=xcb

--------------------------------------------------------------------------------------------------------------

QT_QPA_PLATFORM环境变量用于设置Qt应用程序的平台插件,以指定Qt应用程序在不同图形平台上的行为。这个环境变量的值可以设置为不同的参数,以满足不同的需求。以下是一些常见的QT_QPA_PLATFORM值以及它们的含义:

  1. linuxfb: 使用Framebuffer作为图形输出,适用于嵌入式Linux系统等。

  2. xcb: 使用X Window系统(X11)作为图形输出,这是Linux和Unix系统上常用的默认选项

  3. windows: 使用Windows操作系统上的本机图形接口。

  4. minimal: 使用Qt的最小平台插件,通常用于测试或构建最小化Qt应用程序。

  5. offscreen: 在没有显示器的情况下运行应用程序,通常用于无头(headless)或远程服务器上的应用程序。

  6. android: 用于Android平台上的Qt应用程序。

  7. macos: 用于macOS上的Qt应用程序。

  8. wayland: 使用Wayland图形协议作为图形输出,通常用于现代Linux桌面环境。

  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值