• 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桌面环境。

  • 相关阅读:
    IDL学习:语法基础-对象、哈希表
    【GitHub】github学生认证,使用copilot教程
    SpringCloud-Hystrix
    带你深入Java Log框架,彻底搞懂Log4J、Log4J2、LogBack,SLF4J
    【Linux】C文件系统详解(一)——C文件操作
    设计模式:中介者模式
    今天跟蚂蚁金服安全同学聊聊WAF
    WanAndroid(鸿蒙版)开发的第五篇
    软件企业找第三方软件测评机构做确认测试有什么优势?
    C指针 --- 初阶
  • 原文地址:https://blog.csdn.net/baobei0112/article/details/133310070