我最近安装了PySide 6。我正在运行Ubuntu20.04,试图在VSCode上运行我的代码,并且刚刚运行了:export QT_DEBUG_PLUGINS=1
我收到以下消息:
QFactoryLoader::QFactoryLoader() checking directory path "/home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqeglfs.so"
Found metadata in lib /home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqeglfs.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"eglfs"
]
},
"archreq": 0,
"className": "QEglFSIntegrationPlugin",
"debug": false,
"version": 393216
}
Got keys from plugin meta data QList("eglfs")
QFactoryLoader::QFactoryLoader() looking at "/home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqlinuxfb.so"
Found metadata in lib /home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqlinuxfb.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"linuxfb"
]
},
"archreq": 0,
"className": "QLinuxFbIntegrationPlugin",
"debug": false,
"version": 393216
}
Got keys from plugin meta data QList("linuxfb")
QFactoryLoader::QFactoryLoader() looking at "/home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqminimal.so"
Found metadata in lib /home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqminimal.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"minimal"
]
},
"archreq": 0,
"className": "QMinimalIntegrationPlugin",
"debug": false,
"version": 393216
}
Got keys from plugin meta data QList("minimal")
QFactoryLoader::QFactoryLoader() looking at "/home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqminimalegl.so"
Found metadata in lib /home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqminimalegl.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"minimalegl"
]
},
"archreq": 0,
"className": "QMinimalEglIntegrationPlugin",
"debug": false,
"version": 393216
}
Got keys from plugin meta data QList("minimalegl")
QFactoryLoader::QFactoryLoader() looking at "/home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqoffscreen.so"
Found metadata in lib /home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqoffscreen.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"offscreen"
]
},
"archreq": 0,
"className": "QOffscreenIntegrationPlugin",
"debug": false,
"version": 393216
}
Got keys from plugin meta data QList("offscreen")
QFactoryLoader::QFactoryLoader() looking at "/home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqvnc.so"
Found metadata in lib /home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqvnc.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"vnc"
]
},
"archreq": 0,
"className": "QVncIntegrationPlugin",
"debug": false,
"version": 393216
}
Got keys from plugin meta data QList("vnc")
QFactoryLoader::QFactoryLoader() looking at "/home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqwayland-egl.so"
Found metadata in lib /home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqwayland-egl.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"wayland-egl"
]
},
"archreq": 0,
"className": "QWaylandEglPlatformIntegrationPlugin",
"debug": false,
"version": 393216
}
Got keys from plugin meta data QList("wayland-egl")
QFactoryLoader::QFactoryLoader() looking at "/home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqwayland-generic.so"
Found metadata in lib /home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqwayland-generic.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"wayland"
]
},
"archreq": 0,
"className": "QWaylandIntegrationPlugin",
"debug": false,
"version": 393216
}
Got keys from plugin meta data QList("wayland")
QFactoryLoader::QFactoryLoader() looking at "/home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqwayland-xcomposite-egl.so"
Found metadata in lib /home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqwayland-xcomposite-egl.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"wayland-xcomposite-egl"
]
},
"archreq": 0,
"className": "QWaylandXCompositeEglPlatformIntegrationPlugin",
"debug": false,
"version": 393216
}
Got keys from plugin meta data QList("wayland-xcomposite-egl")
QFactoryLoader::QFactoryLoader() looking at "/home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqwayland-xcomposite-glx.so"
Found metadata in lib /home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqwayland-xcomposite-glx.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"wayland-xcomposite-glx"
]
},
"archreq": 0,
"className": "QWaylandXCompositeGlxPlatformIntegrationPlugin",
"debug": false,
"version": 393216
}
Got keys from plugin meta data QList("wayland-xcomposite-glx")
QFactoryLoader::QFactoryLoader() looking at "/home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqxcb.so"
Found metadata in lib /home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqxcb.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"xcb"
]
},
"archreq": 0,
"className": "QXcbIntegrationPlugin",
"debug": false,
"version": 393216
}
Got keys from plugin meta data QList("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/home/omari/anaconda3/envs/gui_projects/bin/platforms" ...
loaded library "/home/omari/anaconda3/envs/gui_projects/lib/python3.8/site-packages/PySide6/Qt/plugins/platforms/libqxcb.so"
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: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.
我已卸载并重新安装PySide 6,但仍无法使其运行。我不确定我在这条信息中遗漏了什么,以及我需要做什么。
我尝试运行的代码是:
import sys
import random
from PySide6 import QtCore, QtWidgets, QtGui
class MyWidget(QtWidgets.QWidget):
def __init__(self):
super().__init__()
self.hello = ["Hallo Welt", "Hei maailma", "Hola Mundo", "Привет мир"]
self.button = QtWidgets.QPushButton("Click me!")
self.text = QtWidgets.QLabel("Hello World",
alignment=QtCore.Qt.AlignCenter)
self.layout = QtWidgets.QVBoxLayout()
self.layout.addWidget(self.text)
self.layout.addWidget(self.button)
self.setLayout(self.layout)
self.button.clicked.connect(self.magic)
@QtCore.Slot()
def magic(self):
self.text.setText(random.choice(self.hello))
if __name__ == "__main__":
app = QtWidgets.QApplication([])
widget = MyWidget()
widget.resize(800, 600)
widget.show()
sys.exit(app.exec_())
这只是“创建一个简单的应用程序”复制并直接从网站粘贴。
有什么想法吗?或者需要更多的信息?
我还没有从qt中找到任何解决方案。io论坛或与此问题相关的任何其他文章。
编辑
到目前为止,我遇到了一个工作。我可以直接从终端打开文件。但在尝试运行VSCode时,它仍然不起作用。
编辑2
这可能是VSCode扩展问题。PySide或QT将文件保存在. ui中。我的代码在. py中。当将其更改为. ui VSCode时,提示我使用适当的扩展来打开它。我还没有打开它,但我相信这就是我应该看到的。让它在终端打开,而不是VSCode,告诉我这是VSCode没有的东西。
所以我终于让它起作用了。
在我的工作区窗口中,我所要做的就是右键单击该文件,然后在交互窗口中运行当前文件。VSCode提示我下载了一个Jupyter笔记本内核,然后它就工作了!
或者,使用Ctrl Alt N运行代码,而不是Ctrl F5。确保安装了Code Runner扩展。
考虑到该文件在我的终端中工作,我知道它必须是我在VSCode中正在做或没有做的事情。是的,案子结束了。
我花了一段时间专注于我开始学习的这些课程,所以这并不是因为我一直在为这些课程感到压力。我的解决方案是在我试图让matplotlib显示一个我试图运行的图形(第一次使用matplotlib)时出现的,这就是我的工作原理。所以我突然意识到,为了这个代码尝试它,然后砰的一声,它确实以同样的方式工作。
所以,当事情没有按你希望的方式进行时,不要给自己压力。