GNU bug report logs - #70687
python-matplotlib not respecting env var MPLBACKEND=TkAgg

Previous Next

Package: guix;

Reported by: Jake <jforst.mailman <at> gmail.com>

Date: Wed, 1 May 2024 01:25:01 UTC

Severity: normal

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jake <jforst.mailman <at> gmail.com>
To: bug-guix <at> gnu.org
Subject: python-matplotlib not respecting env var MPLBACKEND=TkAgg
Date: Wed, 1 May 2024 01:23:19 +0000
[Message part 1 (text/plain, inline)]
Hello

We are supposed to be able to control the backend used by Python's
Matplotlib via the MPLBACKEND environment variable [1]. This doesn't appear
to work for the TkAgg backend:

#+begin_src sh

  guix shell python python-matplotlib -- bash -c 'MPLBACKEND=TkAgg python3
-c "import matplotlib; print(matplotlib.get_backend()); import
matplotlib.pyplot as plt; plt.plot([1],[2]); plt.show()"'

#+end_src

#+RESULTS:
: TkAgg
: <string>:1: UserWarning: FigureCanvasAgg is non-interactive, and thus
cannot be shown

However, the TkAgg backend does work if it is hardcoded in the Python
script using `matplotlib.use()`:

#+begin_src sh

  guix shell python python-matplotlib -- python3 -c "import matplotlib;
matplotlib.use('TkAgg'); print(matplotlib.get_backend()); import
matplotlib.pyplot as plt; plt.plot([1],[2]); plt.show()"

#+end_src

#+RESULTS:
: TkAgg

Thanks
Jake

[1]: https://matplotlib.org/stable/users/explain/figure/backends.html
[Message part 2 (text/html, inline)]

This bug report was last modified 73 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.