[Insight-users] WrapITK Problem
Gaetan Lehmann
gaetan.lehmann at jouy.inra.fr
Wed Oct 25 10:32:55 EDT 2006
Hi,
On Wed, 25 Oct 2006 15:54:21 +0200, Gheorghe Postelnicu
<gheorghe.postelnicu at gmail.com> wrote:
> Hi,
>
> I have 2 question regarding the Python WrapITK CVS distribution:
>
> 1. when I use the syntax
>
> from itk import * in a python script, I get the message:
>
> Python 2.3.4 (#1, Mar 10 2006, 06:12:09)
> [GCC 3.4.5 20051201 (Red Hat 3.4.5-2)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from itk import *
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "/local/lib/InsightToolkit/WrapITK/Python/itkLazy.py", line 18,
> in __getattribute__
> itkBase.LoadModule(module, namespace)
> File "/local/lib/InsightToolkit/WrapITK/Python/itkBase.py", line 85,
> in LoadModule
> if not swigModuleName in sys.modules: module =
> loader.load(swigModuleName)
> File "/local/lib/InsightToolkit/WrapITK/Python/itkBase.py", line 192,
> in load
> return imp.load_module(name, fp, pathname, description)
> File "/local/lib/InsightToolkit/WrapITK/lib/IntensityFiltersPython.py",
> line 1, in ?
> tionImageFilterINS_5ImageItLj2EEES2_E13CreateAnotherEv
> NameError: name
> 'tionImageFilterINS_5ImageItLj2EEES2_E13CreateAnotherEv' is not
> defined
It works fine for me.
Are you using the last cvs version ?
>
> 2. It seems the Python examples in the ITK directories follow some
> slightly different syntax, namely they use import InsightToolkit.
> However, the install of the WrapITK produces the itk namespace. Is
> this normal?
Yes, that's normal.
The itk namespace has been chosen to be more consistent with c++, and
because it is shorter.
Note that with the old wrappers, you had to do:
from InsighToolkit import *
median = itkMedianImageFilter...
and with the new:
import itk
median = itk.MedianImageFilter...
This last form has a huge advantage compared to the "from itk import *"
you are using: it use the lazy loading, and should save lots of the
loading time
Gaetan
--
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66 fax: 01 34 65 29 09
http://voxel.jouy.inra.fr
More information about the Insight-users
mailing list