Hi,
I am using python and poetry, provided by NixOS to install a poetry virtual environment (no poetry2nix here).
I have set the matplotlib backend to “TkAgg” using the “MPLBACKEND” env var.
But when I try to plot something, the backend reverts to “agg”. I have traced the cause to the misidentificaiton of a headless session, which causes mpl to fallback to “agg” as the backend. The relevant clause is here:
I can force matplotlib to use “TkAgg” with matplotlib.use("TkAgg")
, however this solution isn’t tenable for shared projects.
I assume that this .display_is_valid()
method is returning headless because it can’t find some Wayland or X11 libraries it’s expecting to find. But would appreciate any pointers regarding how I can resolve this.
Many thanks for any help.