[Insight-users] ITK in Python

Erik Anderson eranders at sci.utah.edu
Mon Sep 25 16:05:16 EDT 2006


Zach,
    Thanks for the quick reply.  I rebuilt everything and now, when I 
perform the following commands:
import itk
dir(itk)

I get something totally different than just a list of the classes I 
expect.  Instead, I now get the following:

 >>> dir(itk)
['B', 'D', 'F', 'LD', 'PyCommand', 'PyImageFilter', 'SC', 'SI', 'SL', 
'SS', 'SmartPointer', 'UC', 'UI', 'UL', 'US', 
'_LazyITKModule__lazy_attributes', '__doc__', '__name__', 
'auto_progress', 'class_', 'clrLine', 'ctype', 'echo', 'force_load', 
'image', 'index', 'physical_size', 'pipeline', 'range', 'show', 
'show2D', 'simple_import_callback', 'simple_progress_callback', 'size', 
'spacing', 'strel', 'template', 'terminal_import_callback', 
'terminal_progress_callback', 'write']

Is this what I should be expecting?  I tried to instantiate a filter 
(itk.AcosImageFilter) and get the LazyITKModule object has no attribute 
'AcosImageFilter'  I guess my real question is, did I just take a step 
forward or a step backwards?  The end goal here is to be able to capture 
a list or dictionary of itk modules and the callable functions on those 
modules.

Thanks a lot,
Erik

Zachary Pincus wrote:
> So the general deal here is that the WrapITK Python libs have tricky 
> dependencies, and are slow to load fully. So 'import itk' just gives 
> you a bunch of proxy objects, that when you try to use them, call some 
> code (which can be a bit brittle, as you've seen), to load the actual 
> ITK libraries that are needed.
>
> It would appear that somehow, this loading is getting confused about 
> where to find the files it needs to load. This information should be 
> in (on your system)
> /usr/local/itk/Wrapping/WrapITK/Python/itkConfig.py
>  Could you send the contents of this file?
>
> In general, the python files you need would be in:
> /usr/local/itk/Wrapping/WrapITK/lib
> (I think...). Do you have a file VXLNumericsPython.py in that directory?
>
> Zach
>
>
> On Sep 25, 2006, at 11:55 AM, Erik Anderson wrote:
>
>> Hi all,
>>    I have successfully built ITK and WrapITK with (I think) the 
>> proper CMake options set.  In a Python shell, I am able to 
>> successfully import itk via
>>
>> import itk
>>
>> using dir on the module gives me a list of all the wrappings I would 
>> expect, however, upon instantiation of a class I get the following 
>> type of error:
>>
>> >>> f = itk.AcosImageFilter
>> Traceback (most recent call last):
>>  File "<stdin>", line 1, in ?
>>  File "/scratch/eranders/env/itk/Wrapping/WrapITK/Python/itkLazy.py", 
>> line 18, in __getattribute__
>>    itkBase.LoadModule(module, namespace)
>>  File "/scratch/eranders/env/itk/Wrapping/WrapITK/Python/itkBase.py", 
>> line 77, in LoadModule
>>    LoadModule(dep, namespace)
>>  File "/scratch/eranders/env/itk/Wrapping/WrapITK/Python/itkBase.py", 
>> line 77, in LoadModule
>>    LoadModule(dep, namespace)
>>  File "/scratch/eranders/env/itk/Wrapping/WrapITK/Python/itkBase.py", 
>> line 85, in LoadModule
>>    if not swigModuleName in sys.modules: module = 
>> loader.load(swigModuleName)
>>  File "/scratch/eranders/env/itk/Wrapping/WrapITK/Python/itkBase.py", 
>> line 191, in load
>>    fp, pathname, description = imp.find_module(name)
>> ImportError: No module named VXLNumericsPython
>>
>> My environment is as follows:
>>
>> Python 2.4 on Suse 10.1
>> itk 2.8 built from CVS with WrapITK
>>
>> Environment variables set:
>> LD_LIBRARY_PATH = /usr/local/itk/bin
>> PYTHONPATH=/usr/local/itk/Wrapping/WrapITK/Python
>>
>> Any help would be great.
>>
>> Thansk,
>> Erik Anderson
>>
>>
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org
>> http://www.itk.org/mailman/listinfo/insight-users
>



More information about the Insight-users mailing list