我正在尝试在WSL2上运行一个简单的PySide6应用程序
$ python3 -m venv venv
$ . ./venv/bin/activate
$ pip install PySide6
$ sudo apt install libopengl0 libegl1我的代码:
import sys
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QApplication, QLabel
if __name__ == "__main__":
app = QApplication(sys.argv)
label = QLabel("Hello World", alignment=Qt.AlignCenter)
label.show()
sys.exit(app.exec_())当我运行时,我得到了这个错误
$ export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0\n
$ python main.py
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.
[1] 2557 abort python main.py可以使用WSL2运行PySide应用程序吗?如果是,是如何实现的?
发布于 2021-03-16 12:22:05
i)安装https://sourceforge.net/projects/vcxsrv/
ii) export DISPLAY="`grep nameserver /etc/resolv.conf | sed 's/nameserver //'`:0"
iii)运行xev测试image
iv)在/etc/bash.bashrc文件的末尾包含命令ii:
2、sudo apt install pyside2-tools libopengl-dev
3、运行python3 xxx.py它起作用了,但仍然有一些问题。输出:
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-dev'
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrasthttps://stackoverflow.com/questions/66480279
复制相似问题