469,275 Members | 1,588 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

Python & Mayavi Problem

Hello NG,

I'm trying to follow the mayavi documentation in order to run
mayavi from python. In "Chapter 4. Using MayaVi from Python", there is
a simple example like this:

# generate the data.
from Numeric import *
import scipy
x = (arange(50.0)-25)/2.0
y = (arange(50.0)-25)/2.0
r = sqrt(x[:,NewAxis]**2+y**2)
z = 5.0*scipy.special.j0(r) # Bessel function of order 0
# now dump the data to a VTK file.
import pyvtk
# Flatten the 2D array data as per VTK's requirements.
z1 = reshape(transpose(z), (-1,))
point_data = pyvtk.PointData(pyvtk.Scalars(z1))
grid = pyvtk.StructuredPoints((50,50, 1), (-12.5, -12.5, 0), (0.5,
0.5, 1))
data = pyvtk.VtkData(grid, point_data)

import mayavi
v = mayavi.mayavi() # create a MayaVi window.
d = v.open_vtk('test.vtk', config=0) # open the data file.
# The config option turns on/off showing a GUI control for the
# load the filters.
f = v.load_filter('WarpScalar', config=0)
n = v.load_filter('PolyDataNormals', 0)
n.fil.SetFeatureAngle (45) # configure the normals.
# Load the necessary modules.
m = v.load_module('SurfaceMap', 0)
a = v.load_module('Axes', 0)
a.axes.SetCornerOffset(0.0) # configure the axes module.
o = v.load_module('Outline', 0)
v.Render() # Re-render the scene.

Everything goes fine, but at the end I obtain the mayavi window
completely red (without the expected surface/image), and when I click
on this window I get different errors depending on which Python editor
I run:

1) Pythonwin: Error: Microsoft Visual C++ Runtime Error. Everything
Crashes. After this, I get a vtkwindow coming up and showing me the
"always-present" error message from mayavi:

"Generic Warning: In
/debian/stage/vtk-4.2.4/Rendering/vtkTkRenderWidget.cxx, line 638
A TkRenderWidget is being destroyed before it associated
is destroyed. This is very bad and usually due to the order in which
objects are being destroyed. Always destroy the vtkRenderWindow before
destroying the user interface components"

I don't know why, but with mayavi this warning is EXTREMELY common...

2) IDLE for Python: All is frozen, nothing happen, I have to kill
3) Python Command Line: No windows appears, nothing happen.

Moreover, I would like to be able to compile my Python application to
a standalone EXE file by using py2exe, but py2exe complains about some
missing modules (either from mayavi and for scipy), and the created
EXE does not start.
I have installed Python using the Enthought Installer for Python (with
lots of site-packages inside), located at:


I'm running Win2000, without administrator privileges (if this can
make differences).

Does anyone have an idea?

Thanks for every suggestion.

Jul 18 '05 #1
0 1601

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Yi-Yu Chou | last post: by
699 posts views Thread by mike420 | last post: by
reply views Thread by Emile van Sebille | last post: by
1 post views Thread by Ron Kneusel | last post: by
114 posts views Thread by Maurice LING | last post: by
8 posts views Thread by Georg Brandl | last post: by
9 posts views Thread by Carl | last post: by
10 posts views Thread by anton | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.