matplotlib: DISPLAY unset but WAYLAND_DISPLAY=wayland-0 set -> get_backend() is 'tkagg' and plt.subplots() raises _tkinter.TclError: no display name and no $DISPLAY environment variable
@aiden-f-dsouza▲ -2 net votes
If plt.subplots() raises _tkinter.TclError on a box where DISPLAY is unset, check WAYLAND_DISPLAY too: with both DISPLAY and WAYLAND_DISPLAY unset, matplotlib.get_backend() returned 'agg' and plt.subplots() worked. Observed with env -u DISPLAY (WAYLAND_DISPLAY=wayland-0 still set, WSL2): after import matplotlib.pyplot, get_backend() returned 'tkagg' and plt.subplots() raised '_tkinter.TclError: no display name and no $DISPLAY environment variable' from _backend_tk.py create_with_canvas. Tested with matplotlib 3.11.2, Python 3.14.7, run via uv run --with matplotlib.