Recently I've been making movies by having Mathematica create figures and then I combine all of them together using ffmpeg. The problem now is that my macbook is not fast enough to generate the figures I want in a short amount of time.

I have access to a linux machine and I would like to be able to send a script to that machine so that I can generate my figures. The problem I'm facing is that Mathematica can't open display ":0.0".

enter image description here

I also found this, but it did not solve my problem. Does anyone know how to generate figures in the terminal? All I want it to do is to write them to a file.

  • $\begingroup$ The link you gave seems to indicate that you must have a FrontEnd (or at least a capable windows server) to do anything with Export, or did I misunderstand the link? $\endgroup$
    – tkott
    May 2, 2012 at 20:19
  • $\begingroup$ My answer here will help $\endgroup$
    – rm -rf
    May 2, 2012 at 20:21
  • $\begingroup$ Does it work if you start the kernel with sh -c 'unset DISPLAY; exec math'? $\endgroup$
    – celtschk
    May 2, 2012 at 20:25
  • $\begingroup$ @celtschk, No, it still gives me the same error. $\endgroup$
    – jmlopez
    May 2, 2012 at 20:30
  • 1
    $\begingroup$ Alright then. You should go to the web site http://xquartz.macosforge.org/landing/ and download the latest version of X11 appropriate for your OS X version. After installing it, everything should work. $\endgroup$
    – Jens
    May 2, 2012 at 23:06

3 Answers 3


Since graphics can no longer be exported without access to a front end, even with remote connections you have to have X11 installed and working on your local machine. Therefore, the first thing you should do is: go to the web site http://xquartz.macosforge.org/landing/ and download the latest version of X11 appropriate for your OS X version. After installing it, everything should work.


In view of the comments, it's worth asking what the alternatives are to creating graphics on a remote host. Since the X11 protocol slows down the interaction between Kernel and FrontEnd, it's not practical on Mac OS X to create graphics that way any more. Unless you have older versions of Mathematica running on the remote host, that's the end of the line for this approach.

So what to do? You can hope you have a VNC server so you can start the interactive session entirely on the host. That's a good solution if it's available.

If not, then perhaps you'll be best off running the graphics generation as a background job on your own computer. If you have a multicore machine, you can start a Kernel session in the Terminal and let it run there, while doing other things in an interactive notebook session. At least in this way, you won't have to worry about not finding the FrontEnd.

On my Mac, I've set up a math command that starts /Applications/Mathematica.app/Contents/MacOS/MathKernel from the Terminal (see this page for details), and in such a Kernel session I would then (without calling JavaGraphics) do the graphics generation, e.g.:

t = Table[ParametricPlot3D[{Sin[u], Sin[v], Sin[u + v]}, {u, 0, 2 Pi}, {v,0, 2 Pi}, RegionFunction -> Function[{x, y, z}, z < a], PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}],{a, -1,1,.01}];

While that's running, I'm able to use the Mathematica notebook interface in parallel.

I said not to call JavaGraphics, because once that is initialized the Kernel session will want to display all the pictures you create. One can turn that off again by adding DisplayFunction->Identity to the plot command options, but if the plan is to do a non-interactive job, I'd suggest not loading JavaGraphics in the first place.

  • 6
    $\begingroup$ I wonder what drove Wolfram to this, err, interesting choice. There's nothing inherent in exporting graphics which couldn't be done on a kernel (and even more so, if you don't need to display anything on screen, a connection to a screen should not be required). $\endgroup$
    – celtschk
    May 3, 2012 at 8:55
  • 2
    $\begingroup$ Yes, it cripples any workflow that relied on batch jobs to generate figures. It's bad. $\endgroup$
    – Jens
    May 3, 2012 at 14:19
  • $\begingroup$ It also evidently makes the output of batch jobs dependent on the actual X setup on your server, which adds a kind of fun and excitement to bacth workflows that I would just as happily do without. $\endgroup$
    – Pillsy
    May 3, 2012 at 14:37
  • $\begingroup$ I really thought that this would be more efficient since the kernel will be running in a faster machine but it seems as if the graphics are being generated in my machine over an internet connection and this just makes the whole process way slower. What a bunch of bull... $\endgroup$
    – jmlopez
    May 3, 2012 at 18:34
  • 1
    $\begingroup$ Agreed. E.g., to make movies one uses render farms where the frames are generated and post-processed in background jobs. Since MMA is already quite slow at complex graphics, having no way to offload to background jobs is terrible. I'm surprised they did that. $\endgroup$
    – Jens
    May 3, 2012 at 19:11

The function UsingFrontEnd may help if the machine on which you are running the command has an available FrontEnd.

  • $\begingroup$ David, I edited your answer to include a link to the documentation, as that is an obscure function, in addition to adding code highlighting to it. $\endgroup$
    – rcollyer
    May 3, 2012 at 14:09

I think you need to do two things. First, you need to set up a virtual desktop. Ideally, you should just be able to execute vncserver from the linux command line. If not, you'll have to install it. Second, you're generating graphics from the command line but you'll still the services of a FrontEnd, so execute Developer`InstallFrontEnd[] from within Mathematica.

I think this will work but I'm unable to test at the moment. And I've been wrong before. Many times.

  • $\begingroup$ I don't have control of those machines so I won't be able to install vncserver to try it out. At this moment I do not wish to bother the administrators. I tried the command you gave me and I got: connect /tmp/.X11-unix/X0: No such file or directory Can't open display "localhost:11.0" $\endgroup$
    – jmlopez
    May 2, 2012 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.