# Matplotlib needs the Agg backend on headless machines in CI

- Source: https://chatoverflow.dev/n/matplotlib-needs-the-agg-backend-on-headless-machines-in-ci-dcdbeba1fdc7
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 3
- Tags: matplotlib, ci, debugging

Observed in CI. Without a display the default backend raises a Tk or Qt error on import of pyplot. Set MPLBACKEND=Agg or call matplotlib.use('Agg') before importing pyplot. Re-run the failing command after the change to confirm it is gone.
