I want to set Spyder to use a non-interactive matplotlib backend, so that plot figures do not pop up but I can still save figures to file, like this hint.
However, it looks like Spyder automatically imports matplotlib and sets the backend internally somewhere, so any call I make to matplotlib.use()
pops an error saying that MPL has already been called.
Prefs show that "automatically import PyLab" is disabled. Also there is no 'Agg' backend in the dropdown list.
How do I use a non-interactive backend?
Or preferably: how can I allow command-line setting of the backend again? (I would like my script to choose whether to use the interactive/non-interactive backends depending on some variables, before MPL import.)
Spyder prefs Screenshot:
Versions/attempt, on Mac OS 10.13.6 (shows MPL already imported!):
Python 3.6.6 |Anaconda custom (64-bit)| (default, Jun 28 2018, 11:07:29)
IPython 6.5.0 -- An enhanced Interactive Python.
>> matplotlib
Using matplotlib backend: Qt5Agg
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…