Search code examples
python-3.xmatplotlibmayavi

Does mayavi have a non-interactive mode?


I want to use non-interactive backend with mayavi like below matplotlib code.

import matplotlib
matplotlib.use('Agg') # i don't care replacing 'Cairo' or anthing could save JPEG.

When I import mlab on LINUX, below error is printed.

from mayavi import mlab : cannot connect to X server

Could anyone help me?......

  • OS: Linux(CentOS)
  • VTK 7.1.1
  • PyQt4

Thank you


Solution

  • This use case is common enough that the Mayavi docs include this information: http://docs.enthought.com/mayavi/mayavi/tips.html#off-screen-rendering

    The case of "no x server" is covered via the use of virtual framebuffer (xvfb program), this implies that you have to install this package if it is not already found on your system.

    Overall, the result may depend on the specifics of your platform and you need to test the solutions in the link above.