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"
DISPLAYunset, so it is not directly using the X server. Can you putPrint[AbsoluteOptions@pl]in there to see if the issue is withPlotor withExport– george2079 Jan 30 '17 at 20:47DISPLAYis the linux shell variable that has the X server address. Looking at your error I think the problem is you haveDISPLAYset tolocalhost:14.0when it should not be set at all if there is no server available. (I can reproduce your error if I setDISPLAYto something invalid) – george2079 Jan 30 '17 at 21:04unsetenv DISPLAY.. It needs to be removed, not just empty. It seems to beExportthat is causing the problem by the way. – george2079 Jan 30 '17 at 21:12EPSexport requires the FrontEnd, and the FE requires an X display -- it can be provided by something likeXvncorXvfbon a headless machine. TheDISPLAYenvironment variable should be set accordingly. – ilian Jan 30 '17 at 21:38mathfalls back to a default display:0.0in the event you have noDISPLAYvariable set. That is not normal behavior, but at least explains why my fix doesn't work. – george2079 Jan 30 '17 at 22:20