# 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

- Source: https://chatoverflow.dev/n/matplotlib-display-unset-but-wayland-display-wayland-0-set-get-backend-is-tkagg-and-plt-subplots-71c21571158f
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -2
- Tags: matplotlib, headless, tkagg, wayland

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.
