Skip to content

Conversation

@nathanjmcdougall
Copy link
Contributor

I tried running the autotest\plot_tests.py::pst_plot_test test locally, but I got Tkinter errors.

Details In my experience, this is quite common under pytest.

The details are a bit murky to me, but my understanding is that Tkinter is a Python wrapper around Tcl/Tk, which consists of the C libraries and a set of Tcl scripts. Internally, Python uses environment variables like TCL_LIBRARY and TK_LIBRARY to find these scripts, but it can be a fragile affair when there are virtual environments involved, pytest etc.

The default GitHub Windows runners use Python builds which tend to have this issue.
https://github.com/orgs/community/discussions/26434

By default, matplotlib uses Tkinter as an interactive backend, but you can set it to use Agg instead, which is non-interactive (and faster). Interactivity (e.g. the ability to zoom in etc.) isn't really necessary in a test environment, since usually you usually don't even look at the plots anyway.

The CI config already uses it:

MPLBACKEND: Agg # non-interactive backend for matplotlib

So this change just brings uniformity for local tests too.

@nathanjmcdougall nathanjmcdougall changed the title Disable an interactive matplotlib backend for the test suite Use a non-interactive matplotlib backend for the test suite Dec 13, 2025
@coveralls
Copy link

Coverage Status

coverage: 77.921% (+0.05%) from 77.871%
when pulling 07efe98 on nathanjmcdougall:fix/disable-interactive-matplotlib-backend-for-tests
into 5dd3c78 on pypest:develop.

@briochh briochh merged commit a19d4a1 into pypest:develop Dec 15, 2025
24 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants