Exporting graphics on a headless Pi
Posted: Fri Nov 22, 2013 3:02 pm
Mathematica can not export any format of graphics witohut the front-end running. It will display these error messages:
To be able to export graphics on a Pi that does not run a front-end, for example on a headless server, you have to install Xvfb (or a similar program that emulates a display).
Then you start mathematica like this if you want 24 bit graphics:
or if you want 8 bit graphics:
And it will work:
(On my first-gen 256 MB model B it takes about 50 seconds to render the graphics with 24 bit colors.)
Code: Select all
In[3]:= p=Plot[Sin[x],{x,0,2 Pi}]
Out[3]= -Graphics-
In[4]:= Export["testplot.png",p]
Developer`LaunchFrontEnd::nxsrv: An x server is required for that operation.
Rasterize::nofe: A front end is not available; Rasterize requires a front end.
Out[4]= $FailedThen you start mathematica like this if you want 24 bit graphics:
Code: Select all
xvfb-run -s "-screen 0 640x480x24" /opt/Wolfram/WolframEngine/10.0/Executables/mathCode: Select all
xvfb-run -s "-screen 0 640x480x8" /opt/Wolfram/WolframEngine/10.0/Executables/mathCode: Select all
In[1]:= p=DensityPlot[{Sin[Sqrt[x] + Log[y]]}, {x, 0, \[Pi]^2}, {y, 0, E^\[Pi]}]
Out[1]= -Graphics-
In[2]:= Export["testplot24.png",p]
Out[2]= testplot24.png