Setting the matplotlib backend

Running matplotlib on OS X, occasionally there will be a cryptic error about installing as a framework. See here for a more precise discussion. The fix I typically use, and which is hard to find (on this page) is to run

import matplotlib
matplotlib.matplotlib_fname()

then go to the printed file, find the line that says 'macosx', and change it to 'Agg'.

Or, as a bash command, python -c 'import matplotlib; print(matplotlib.matplotlib_fname())'