VScode用SSH连接远程服务器配置PyQT出现’xcb‘错误的解决方案

在进行PyQT的配置时,环境变量等都设置正确,但点击PyQT:New Form时还是会出现这样的错误:Error: Command failed: "/opt/conda/envs/SAM/lib/python3.8/site-packages/qt6_applications/Qt/bin/designer" qt.core.plugin.factoryloader: checking directory path "/opt/conda/envs/SAM/lib/python3.8/site-packages/qt6_applications/Qt/plugins/platforms" ... qt.core.plugin.factoryloader: looking at "/opt/conda/envs/SAM/lib/python3.8/site-packages/qt6_applications/Qt/plugins/platforms/libqvnc.so" qt.core.plugin.loader: Found metadata in lib /opt/conda/envs/SAM/lib/python3.8/site-packages/qt6_applications/Qt/plugins/platforms/libqvnc.so, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "vnc" ] }, "archlevel": 1, "className": "QVncIntegrationPlugin", "debug": false, "version": 394496 } qt.core.plugin.factoryloader: Got keys from plugin meta data QList("vnc") qt.core.plugin.factoryloader: looking at "/opt/conda/envs/SAM/lib/python3.8/site-packages/qt6_applications/Qt/plugins/platf...

解决方法:

第一步:运行cd /home/curiouspan/qt6-build/qtbase/plugins/platforms/libqxcb.so 以显示依赖项

我这里依赖性均存在,若出现not found的情况,需要安装相关.so

第二步:在终端输入 vim ~/.bashrc,并在最后一行加入 QT_DEBUG_PLUGINS=1 ,保存后在终端再运行source ~/.bashrc,再进入VScode执行PyQT:New Form可以让报错更详细

qt.core.plugin.factoryloader: Got keys from plugin meta data QList("eglfs")
qt.core.plugin.factoryloader: checking directory path "/opt/conda/envs/SAM/lib/python3.8/site-packages/qt6_applications/Qt/bin/platforms" ...
qt.core.library: "/opt/conda/envs/SAM/lib/python3.8/site-packages/qt6_applications/Qt/plugins/platforms/libqxcb.so" loaded library
qt.qpa.xcb: could not connect to display 
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: vnc, wayland-egl, linuxfb, minimalegl, xcb, offscreen, minimal, vkkhrdisplay, wayland, eglfs.

第三步:在终端输入 echo $DISPLAY得到返回结果

第四步:打开左边调试和运行栏,点开设置

在launch.json文件中添加

env": {
                "DISPLAY": "28f80d19e7dc:11.0"
            }

 成了!

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值