Matplotlib running under cron

I have been successfully producing graphics as pngs with matplotlib and
running them as cron jobs with Linux for some time. These graphics used
"standard" colors.

I recently changed some of the colours, using tuples of RGB values instead
of the standard colors and now the scripts will run from the command line,
but not as scheduled cron jobs and I get the following error:

Unable to access the X Display, is $DISPLAY set properly?

The script then terminates.

Can anyone help me with how to set the display in cron and run Matplotlib
as a cron job.

Thanks
John

This is usually caused by having an interactive backend (such as Gtk, Qt, Tk) which would require X11. Try setting your backend to "Agg".

  import matplotlib
  matplotlib.use("Agg")

Cheers,
Mike

···

john.bacon@...2566... wrote:

I have been successfully producing graphics as pngs with matplotlib and
running them as cron jobs with Linux for some time. These graphics used
"standard" colors.

I recently changed some of the colours, using tuples of RGB values instead
of the standard colors and now the scripts will run from the command line,
but not as scheduled cron jobs and I get the following error:

Unable to access the X Display, is $DISPLAY set properly?

The script then terminates.

Can anyone help me with how to set the display in cron and run Matplotlib
as a cron job.

Thanks
John

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA