[Image-SIG] Re: rpy and cgi

Fredrik Lundh fredrik@pythonware.com
Mon, 26 May 2003 13:13:23 +0200

Daryl Shanley wrote:

> I've recently been exploring using the RPy interface to R
> for producing some graphs using a series of commands such
> as;

> This works fine when the python file is run from a command
> line, but when I incorporate these same commands into a cgi
> file I get an 'internal server error'. I'm using an Apache web
> server and the error log reads
>  unable to open connection to X11 display`'
> Premature end of script headers: /usr/lib/cgi-bin/test/test.py
>  Execution halted

> Does anybody have any ideas?

I don't know anything about RPy/R, but the error message indicates
that the software requires a working X window server.

you could try adding the following to your CGI script, before you
import/invoke RPy:

    import os
    os.environ["DISPLAY"] = "server:0.0"

where "server" should be replaced with the name of a machine
that has an X server, and that is always running...

for more reliable operation, you should check if you can run RPy
without an X server.