Plotting in batch with no display

Emile van Sebille emile at fenx.com
Fri Jun 4 17:13:38 EDT 2010


On 6/4/2010 1:01 PM Hans Georg Schaathun said...
> Admittedly not the strongest reason, but yet an important one,
> for switching from Matlab to python/numpy/scipy/matplotlib,
> is that Matlab is very cumbersome to run in batch.
>
> Now I discover that some of the matplotlib.pyplot functions
> (incl. plot and contour) insist on opening an X11 window
> (just like Matlab does).

I found the same to be true when running OpenOffice in batch mode. 
Ultimately, the following was key to getting things going:

at the shell:

/usr/bin/vncserver :1


then from within python:

XDISPLAY=':1'

cmd='''cd /usr/ftp/CSV && DISPLAY=%s \
     /usr/bin/soffice -norecover -nologo -nodefault \
     "macro:///Standard.Module1.csvToXLS(%s)"''' \
     % (XDISPLAY,csvfile)

dummy = commands.getoutput(cmd)


Then, if it doesn't run to conclusion, you can vnc to :1 and see where 
it's stalled out.

HTH,

Emile





More information about the Python-list mailing list