在进行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"
}
成了!