On 7/22/07, JJ <[EMAIL PROTECTED]> wrote:
> Hello all:
> I am developing a website, initially on my local
> machine using the apache httpd server.  My linux box
> has scipy/numpy/pylab installed, and they work fine
> from a terminal.  However, I need to use the programs
> in a cgi script and am having problems getting them to
> import.  When I try to import pylab I get the
> following error:

> File
> "/usr/lib64/python2.4/site-packages/gtk-2.0/gtk/__init__.py",
> line 64, in _init  _gtk.init_check()
> RuntimeError: could not open display

You need to set your graphics "backend" to a pure image backend.  Eg,
at the start of your script, before importing pylab, do

import matplotlib
matplotlib.use('Agg')

pylab may not be your best choice for a web app server, you may want
to consider using the matplotlib API directly because it gives you a
bit more control

http://matplotlib.sourceforge.net/faq.html#OO


>
> Im sure this is easy to fix, but how would I go about
> doing it?  I want to save jpg files from computed data
> and then serve them up to a web page.

JPG is usually not a good choice for line graphs and text, PNG is
better for this, and agg will make these.  If you need JPG, you can
either convert the agg output, or use a different backend, eg I
suspect cairo supports JPG output.

JDH

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to