nasty import behavior

A python module of mine could draw a plot, and so imports from matplotlib.
Actually, plotting is part of the module test that is in
if __name__==__main__

But this kills my job trying to run non-interactively.
This is IMO rather nasty behavior. matplotlib should not try to open the
display just because you import it.

    from matplotlib.pyplot import *
  File "/usr/lib64/python2.6/site-packages/matplotlib/pyplot.py", line 78,
in <module>
    new_figure_manager, draw_if_interactive, show = pylab_setup()
  File "/usr/lib64/python2.6/site-packages/matplotlib/backends/__init__.py",
line 25, in pylab_setup
    globals(),locals(),[backend_name])
  File "/usr/lib64/python2.6/site-
packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module>
    from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK,
FigureCanvasGTK,\
  File "/usr/lib64/python2.6/site-
packages/matplotlib/backends/backend_gtk.py", line 8, in <module>
    import gtk; gdk = gtk.gdk
  File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line
64, in <module>
    _init()
  File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line
52, in _init
    _gtk.init_check()
RuntimeError: could not open display

You need to set your backend to a non-GUI one (such as Agg) if you want
to run without a display. This FAQ answer may be helpful:

http://matplotlib.sourceforge.net/faq/howto_faq.html#matplotlib-in-a-web-application-server

Mike

···

http://p.sf.net/sfu/sprint-com-firstMatplotlib-devel@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/matplotlib-devel

-- Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA