[vtkusers] Problem VTK4 + python 2.2

David Gobbi dgobbi at irus.rri.ca
Mon Jan 14 12:38:21 EST 2002


Specifically, the "ValueError: method requires a VTK object" error occurs
because the VTK wrappers check the type using the following method in
vtkPythonUtil.cxx:

  int PyVTKObject_Check(PyObject *obj)
  {
    return (obj->ob_type == &PyVTKObjectType);
  }

i.e. it checks the 'type' filed of the python object to see if it matches
the static pointer "PyVTKObjectType."  So if the contents of
vtkPythonUtil.cxx are included twice into the final running application,
there will be multiple "PyVTKObjectType" values and errors will result.

Possible causes are bad static linkage i.e. vtkPythonUtil.cxx being
compiled into each of the libvtkPython*.so modules (this doesn't happen
in the current VTK) or .so files from different versions of VTK somehow
being included into the same application (as Prabhu mentions).

 - David

--
  David Gobbi, MSc                       dgobbi at irus.rri.ca
  Advanced Imaging Research Group
  Robarts Research Institute, University of Western Ontario

On Mon, 14 Jan 2002, Prabhu Ramachandran wrote:

> >>>>> "JP" == Jose Paulo Moitinho de Almeida <moitinho at civil.ist.utl.pt> writes:
>
>
>     JP>     def init_scalar_bar (self): "Sets up the default scalar
>     JP> bar."  debug ("In LutHandler::init_scalar_bar ()") self.sc_bar
>     JP> = vtkpython.vtkScalarBarActor () self.sc_bar.SetLookupTable
>     JP> (self.lut)
>
>     JP> I got in the SetLookupTable command a: "ValueError: method
>     JP> requires a VTK object (in init_scalar_bar)"
>
> Ahh, I remember this one.  I had this happen to me long back.  IIRC,
> this happens when you have two copies of the VTK libraries accessible
> in different places and when a module is somehow imported twice.  In
> my situation I had built VTK with the libs in
> /skratch/prabhu/vtk/cvs/VTK/lib and I had also copied those libraries
> to another directory to make some binaries.  I had my LD_LIBRARY_PATH
> set to the directory /skratch/prabhu/vtk/cvs/VTK/lib and even when I
> unset it and set it to the current directory (where I had copied the
> libs) I would get this ValueError exception.  What I finally needed to
> do was to change the name of the build directory from lib to lib1 (I
> just moved the lib dir to lib1) and things worked.  I think the
> problem is because the libvtk modules are being imported twice.  It
> was Gordon McMillan who suggested this possibility to me.
>
> prabhu
>




More information about the vtkusers mailing list