[vtkusers] KeyError: 'vtk.patented' when using VTK with Python 2.4 on Suse 9.3

Jens Thomas j.m.h.thomas at dl.ac.uk
Mon Jul 18 07:06:01 EDT 2005


Hello

I've been using vtk for a while now with no problems, but have just 
upgraded the Linux boxes I run at work from Suse 9.0 to 9.3. It seems 
that this has upgraded my Python installation from 2.3 (I think) to 2.4.

Now, when I try to import vtk, I get the following error:

 >>> import vtk
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File 
"/home/jmht/downloads/VTK/VTK_build/Wrapping/Python/vtk/__init__.py", 
line 55, in ?
    __helper.refine_import_err('patented', exc)
  File 
"/home/jmht/downloads/VTK/VTK_build/Wrapping/Python/vtk/__helper.py", 
line 12, in refine_import_err
    del sys.modules['vtk.%s'%mod_name]
KeyError: 'vtk.patented'

I thought the problem might be that I needed to rebuild vtk against 
python 2.4, so I took the same souce code I used for the original build 
and rebult vtk, but still got the same error.

Looking at the code that causes the import error, it looks like the 
funtion refine_import_error is called in  
Wrapping/Python/vtk/__init__.py when a module can't be imported and is 
supposed to check if this is a link error or due to the module not 
having been built. However, the first line of the refine_import_error is:

del sys.modules['vtk.%s'%mod_name]

which as I read it tries to delete the module from the namespace and is 
where the error occurs. My understanding is that we are only ending up 
here because we experienced an import error so by definition the module 
shouldn't be here to be deleted. Removing this line allows my code to 
work fine.

I don't know if my explanation above is correct, but even if it is and 
it is a problem with the vtk python code I can't understand why I've 
only hit this error after upgrading as  I'm using the same vtk source I 
was before (4.4) and it's only the stuff around vtk that has changed.

If anyone could set me straight on this I'd be most grateful - I'll 
happily supply more information on request.

Best wishes,

Jens



More information about the vtkusers mailing list