In order for production code to run on machines with different python installations it needs to call
import matplotlib as mpl
mpl.use('Agg')
This is super annoying because it throws the warning
warnings.warn(_use_error_msg) /home/keith/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/init.py:1312: 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.
on some of the machines. I would like to suppress this and only this message. I know I can call
import warnings
warnings.filterwarnings("ignore")
but this might cause me to miss other warnings.
--------------Edit---------------
I have found what may be a solution but I am unsure
import warnings
import matplotlib as mpl
with warnings.catch_warnings():
warnings.simplefilter("ignore")
mpl.use('Agg')