Problem
Actually it is not user-friendly to run Matplotlib on WSL.
Moreover, this answer python - Show matplotlib plots (and other GUI) in Ubuntu (WSL1 & WSL2) - Stack Overflow is outdated.
Since WSL2 implements the Wayland protocol and the OpenGL API, Matplolib should detect it is running on WSL and select automatically the right backend or raises an informative error message.
To detect WSL, we can rely on:
uname kernel
- or the presence of
/etc/wsl-distribution.conf
For the backend, we can use:
- Qt Agg with PyQt5 and set the env
QT_QPA_PLATFORM=wayland (PySide2 seems to crash)
- to be completed Qt6 GTK Vulkan...
QT_QPA_PLATFORM is mandatory since Qt is probably not able to detect WSL and select the right backend.
RESUME for USERS: YOU DON'T NEED X11 ! It should work out of the box !
Proposed solution
No response
Problem
Actually it is not user-friendly to run Matplotlib on WSL.
Moreover, this answer python - Show matplotlib plots (and other GUI) in Ubuntu (WSL1 & WSL2) - Stack Overflow is outdated.
Since WSL2 implements the Wayland protocol and the OpenGL API, Matplolib should detect it is running on WSL and select automatically the right backend or raises an informative error message.
To detect WSL, we can rely on:
unamekernel/etc/wsl-distribution.confFor the backend, we can use:
QT_QPA_PLATFORM=wayland(PySide2 seems to crash)QT_QPA_PLATFORMis mandatory since Qt is probably not able to detect WSL and select the right backend.RESUME for USERS: YOU DON'T NEED X11 ! It should work out of the box !
Proposed solution
No response