Rich Shepard wrote: > I just upgraded my Slackware-11.0 workstation from matplotlib-0.90.1 to > -0.91.2. When I now start my application I see this: > > /usr/lib/python2.4/site-packages/matplotlib/__init__.py:753: UserWarning: > This call to matplotlib.use() has no effect > because the the backend has already been chosen; > matplotlib.use() must be called *before* pylab, matplotlib.pyplot, > or matplotlib.backends is imported for the first time. > > warnings.warn(_use_error_msg) > > I don't know to which matplotlib.use() call the message refers. At the top > of the module in which matplotlib is used I have > matplotlib.use('WXAgg') > > and the above warning did not appear with the prior version of the library. > > Please help me to understand what changed, and how to fix the change so > the warning no longer appears.
What changed is that I added a warning where previously there was only a silent error--the matplotlib.use command was being ignored. Sometimes this (ignoring the command) is harmless, but it is never the user's intent and in some cases it can cause puzzling problems. It often occurs when a script or module does "from pylab import *" or "import pylab as P", and then later "import matplotlib; matplotlib.use('Agg')". In this example, the user intends to make plots non-interactively, writing them to files, but the whole gui machinery for the default backend (e.g., gtkagg or wxagg or tkagg) is imported unintentionally. One way to find out where the warning is coming from is to invoke your script as python -Werror myscript.py which will turn the warning into an error and thereby trigger an exception traceback. What this will *not* tell you is where the *earlier* call to matplotlib.use() is occurring. To find it you will have to trace back through your application, looking for the first place where pylab, matplotlib.pyplot, or matplotlib.backends is imported, or the first explicit use of matplotlib.use(), whichever is earliest. Eric ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users