ssugrim-kryptowire / markovExample

An example documentation project.
2 stars 0 forks source link

Drawing fails on Wayland desktop #2

Open ssugrim-kryptowire opened 1 year ago

ssugrim-kryptowire commented 1 year ago

When running the code in ubuntu 22.04 with the default desktop (wayland), @ssugrim-kryptowire gets the follow error:

Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.

This is due to matplotlib trying to open a window and is probably tied to some QT issues.

ssugrim-kryptowire commented 1 year ago

This seems to be a well documented issue:

The root cause seems to be a missing qt plugin. This might not be resolvable in conda, this might require the host OS to install the deb package via apt.

ssugrim-kryptowire commented 1 year ago

The apt repo doesn't have a qt5-wayland as indicated in stack overlfow:

(seqexp) jsugrim@JSG:~/VMSHARED/src/markovExample$ apt search qt5-wayland
Sorting... Done
Full Text Search... Done
gambas3-gb-qt5-wayland/jammy 3.16.3-3 amd64
  Gambas Qt5 Wayland component

Instead it seems that is is named qtwayland5:

(seqexp) jsugrim@JSG:~/VMSHARED/src/markovExample$ apt search qtwayland5
Sorting... Done
Full Text Search... Done
qtwayland5/jammy 5.15.3-1 amd64
  QtWayland platform plugin

However, installing this package did not fix the issue. Even specifying the platform variable did not resolve the problem:

(seqexp) jsugrim@JSG:~/VMSHARED/src/markovExample$ QT_QPA_PLATFORM=wayland python3 seq_exp.py 
2023-06-05 13:28:12,560 - seq_exp.py -  INFO - 111 case:
2023-06-05 13:28:16,998 - seq_exp.py -  INFO - [3, 331.0, 783.0, 1522.0, 10680]
2023-06-05 13:28:16,998 - seq_exp.py -  INFO - 121 case:
2023-06-05 13:28:20,926 - seq_exp.py -  INFO - [3, 297.0, 712.5, 1398.0, 9469]
2023-06-05 13:28:20,926 - seq_exp.py -  INFO - 123 case:
2023-06-05 13:28:24,736 - seq_exp.py -  INFO - [3, 286.0, 678.0, 1352.0, 12485]
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in ""
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, minimal, minimalegl, offscreen, vnc, webgl, xcb.
ssugrim-kryptowire commented 1 year ago
After some searching on qt libs and random results, it turns out that the problem was with the code. The original code was written in spyder which does an auto draw of any figures created in the matplot lib library. Since the current version was being run in either vs code or from the command line, the code needed a plt.show() call to actually initiate the drawing. After adding that line the graph generation works (with wanings): image
Successful run with warnings.
ssugrim-kryptowire commented 1 year ago

Several things were discovered while trying to resolve this issue:

  1. the default qt-dev library of the wayland plugin are not installed on the ubuntu 22.04.
  2. The env variables mentioned in the error can be set, some of them make the warinings go away, but there wasn't a diagram. The reason was that the missing line, not the config. The xcb mode worked, but the eglfs and minimalegl were problematic.
    eglfs, minimal, minimalegl, offscreen, vnc, webgl, xcb.
  3. Matplot lib has different drawing back ends and you an swap them using the MPLBACKEND variable. For example:
    MPLBACKEND=TkAgg python seq_exp.py

Other refs:

ssugrim-kryptowire commented 1 year ago

commit b2610f1 resolves the issue