0
votes

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: enter image description here

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
1
I think the option you are looking for is to turn support off, i.e. deactivate "Activate support". Then Spyder will just execute whatever you type in your script.ImportanceOfBeingErnest
Another question with solutions: stackoverflow.com/questions/44086597/…Demis

1 Answers

0
votes

(Spyder maintainer here) As mentioned by @ImportanceOfBeingErnest in his comment above, you simply need to turn off the option called Activate Support in the screenshot you posted to be able to set by yourself the Matplotlib backend you want to use in your code.