Anaconda on Mac: Can't set Matplotlib backend to Agg

那年仲夏 提交于 2019-12-11 15:35:11

问题


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

回答1:


(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.



来源:https://stackoverflow.com/questions/53617655/anaconda-on-mac-cant-set-matplotlib-backend-to-agg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!