Context
I would like to run mathematica scripts on a remote cluster in order to produce some plots. This cluster does not have X11 installed (the job is submitted to a queuing system).
Problem
I have a script file which, say contains
Print["starting"]; pl= Plot[x,{x,0,1}]; Export["test.eps",pl];
in a test.m
file;
But the line command
math -script test.m
seems to require a display.
A few versions of mathematica ago (<7?) it would work with the option
pl= Plot[x,{x,0,1},DisplayFunction->Identity];
cf this page. But this trick does not seem to work anymore, as mathematica seems to require a front-end to do the plot, even if it is not displayed in practice.
Question
With Mathematica 10.0 or 11.0 how does one produce plots without display?
Update
The issue is not with finding the Mathematica Kernel. The script runs fine until the lack of display is a problem.
starting
Can't open display "localhost:14.0"
DISPLAY
unset, so it is not directly using the X server. Can you putPrint[AbsoluteOptions@pl]
in there to see if the issue is withPlot
or withExport
$\endgroup$DISPLAY
is the linux shell variable that has the X server address. Looking at your error I think the problem is you haveDISPLAY
set tolocalhost:14.0
when it should not be set at all if there is no server available. (I can reproduce your error if I setDISPLAY
to something invalid) $\endgroup$unsetenv DISPLAY
.. It needs to be removed, not just empty. It seems to beExport
that is causing the problem by the way. $\endgroup$math
falls back to a default display:0.0
in the event you have noDISPLAY
variable set. That is not normal behavior, but at least explains why my fix doesn't work. $\endgroup$