Issues Running App on WSL2 Ubuntu / Win 11
-
I want to make a small trading terminal application fairly quickly with similar functionality to other applications such as MetaTrader 5.
I'm using WSL2 Ubuntu 22 inside a Windows 11 installation.I'm trying to run code from this quickstart:
https://doc.qt.io/qtforpython-6/quickstart.htmlMy hello_world.py code looks like this:
import sys import random import os 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) self.layout.addWidget(self.text) self.layout.addWidget(self.button) 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())
When I run
python hello_world.py
, I get this error:libEGL warning: MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri) qt.qpa.wayland: Failed to initialize EGL display 3001
I also noticed that the window that appears doesn't have any close or maximize boxes as is depicted in the tutorial.
I'm concerned with the appearance of the window and the errors that I am getting, even though the button inside the window works fine.
What should I do at this point, if anything?
-
It seems those are the usual Wayland issues; can you run with X11? Is there any reason for using WSL at all - PySide also works on Windows.
-
@friedemannkleint I use WSL for most development tasks. Is WSL disadvantageous for this use case?
And to run qt applications with x11, would I do this?
export QT_QPA_PLATFORM=xcb
-
I am not sure what GUI libraries/environment WSL supports. X11/XCB would be preferable.