I need to set the backend for matplotlib in order to apply this solution for addressing issues with non-thread-safe code in Tkinter and using the Tk backend in matplotlib. According to the post I need to do
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
but setting the backend must be done before any imports of pyplot. I thought I found the first import, but I keep getting this warning:
/usr/lib/python2.7/dist-packages/matplotlib/__init__.py:1352: UserWarning: This call to matplotlib.use() has no effect because the backend has already been chosen;
matplotlib.use() must be called *before* pylab, matplotlib.pyplot, or matplotlib.backends is imported for the first time.
My codebase is somewhat large and complex, so it's becoming a pain for me to try to track down where the very first import of pyplot is. Is there a way to test this programmatically, or is there a debug tool I can use to figure this out?