I have been attempting to run the following python code (from Enthought's website) to test the animation capabilities of Enthought's Mayavi module.
from mayavi import mlab
import numpy
n_mer, n_long = 6, 11
pi = numpy.pi
dphi = pi/1000.0
phi = numpy.arange(0.0, 2*pi + 0.5*dphi, dphi, 'd')
mu = phi*n_mer
x = numpy.cos(mu)*(1+numpy.cos(n_long*mu/n_mer)*0.5)
y = numpy.sin(mu)*(1+numpy.cos(n_long*mu/n_mer)*0.5)
z = numpy.sin(n_long*mu/n_mer)*0.5
# View it.
l = mlab.plot3d(x, y, z, numpy.sin(mu), tube_radius=0.025, colormap='Spectral')
# Now animate the data.
ms = l.mlab_source
for i in range(10):
x = numpy.cos(mu)*(1+numpy.cos(n_long*mu/n_mer +
numpy.pi*(i+1)/5.)*0.5)
scalars = numpy.sin(mu + numpy.pi*(i+1)/5.)
ms.set(x=x, scalars=scalars)
However, upon execution, nothing happens. It runs without errors but only the TVTK Scene window pops up blank - no image, no animation. Could the problem lie in the Mayavi module import? The example on the website starts with:
from enthought.mayavi import mlab
whereas, I have:
from mayavi import mlab
The 'enthought.mayavi' import string does not work for me. The Mayavi I'm using is a pip installation.
What should I do to fix this? I'm using Mac OSX 10.8.2. Thanks in advance.