[vtk-developers] VTK/Python automatic pythonpath
Prabhu Ramachandran
prabhu at aero.iitm.ernet.in
Sat Dec 7 09:06:12 EST 2002
Hi Andy,
>>>>> "AC" == Andy Cedilnik <andy.cedilnik at kitware.com> writes:
AC> Hi Prabhu, I don't know about the infamous "ValueError",
AC> but...
I just tested a few things. It appears that vtkpython does solve the
ValueError problem because it makes sure that if the build dir exists
the Python modules (libvtk*Python*) are imported from the build dir.
The ValueError can be triggered easily as follows:
1. Build VTK from sources.
2. Install VTK using make install
3. Install VTK-Python: cd Wrapping/Python; python setup.py install
4. Run the following in the python interpreter.
import vtk
p = vtk.vtkPolyData()
m = vtk.vtkPolyDataMapper()
m.SetInput(p)
If you are in luck you will get an exception that says:
"ValueError: method requires a VTK object".
What happens I believe is that different copies of the module are
loaded (because of the rpath settings) and the vtkPolyData object
instantiated from the library in the build dir causes this trouble.
Running the above with vtkpython does not trigger this error because
it inserts the build dir in the path up front. This means only the
modules in the build dir are loaded. I've even tested it with MayaVi
(which is where most folks seem to encounter this problem).
So in short, if one has a build dir and an install from that build
vtkpython does solve the ValueError problem. Using plain old python
can trigger the ValueError if the build version of the library is in
the path.
AC> The case where this will break is the same as where VTK/Tcl
AC> will break. This is the case where you build VTK, install it,
AC> then change source of VTK and try to run script.
Yes, so long as you did not install VTK-Python using the setup.py
script. If you do that vtkpython works fine and finds the VTK modules
from the installed place.
I'll update the README to this effect sometime.
cheers,
prabhu
More information about the vtk-developers
mailing list