[matplotlib-devel] nasty import behavior

2010-07-08 Thread Neal Becker
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

Re: [matplotlib-devel] nasty import behavior

2010-07-08 Thread Michael Droettboom
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 On 07/08/2010 08:26 AM, Neal Becker wrote: A python module of

Re: [matplotlib-devel] nasty import behavior

2010-07-08 Thread Neal Becker
Thanks for the info, but I still think this is rude behavior for a python module, and believe it would be a good thing to fix it. Michael Droettboom wrote: 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:

Re: [matplotlib-devel] nasty import behavior

2010-07-08 Thread John Hunter
On Thu, Jul 8, 2010 at 9:16 AM, Neal Becker ndbeck...@gmail.com wrote: Thanks for the info, but I still think this is rude behavior for a python module, and believe it would be a good thing to fix it. Generally we try and make it easy for the user to express their intention rather than guess

Re: [matplotlib-devel] nasty import behavior

2010-07-08 Thread Neal Becker
Use case is I have a module that does digital design. If run as main, it has a little test that does a plot. The plot is supposed to use a gui and display. But if not run as main, there is no plot, and maybe no display. I had: if __name__ == __main__: from matplotlib.pyplot import * but

Re: [matplotlib-devel] nasty import behavior

2010-07-08 Thread Michael Droettboom
It's not that simple. In order to get text metrics and start laying out a plot for some backends (notably Gtk and Wx), the GUI framework needs to be imported. Sure, we could import them on demand once the user actually starts doing stuff, but that would require sprinkling the code with

Re: [matplotlib-devel] nasty import behavior

2010-07-08 Thread Drain, Theodore R (343P)
] nasty import behavior It's not that simple. In order to get text metrics and start laying out a plot for some backends (notably Gtk and Wx), the GUI framework needs to be imported. Sure, we could import them on demand once the user actually starts doing stuff, but that would require sprinkling

Re: [matplotlib-devel] nasty import behavior

2010-07-08 Thread Ryan May
On Thu, Jul 8, 2010 at 9:53 AM, Neal Becker ndbeck...@gmail.com wrote: Use case is I have a module that does digital design.  If run as main, it has a little test that does a plot.  The plot is supposed to use a gui and display. But if not run as main, there is no plot, and maybe no display.