[Insight-users] Compile itk with python bindings

Julien Lamy lamy at unistra.fr
Mon Feb 22 05:22:48 EST 2010


Hi Simon,

Le 22/02/2010 00:24, Simon Su a écrit :
> Hello,
> I manage to compile itk but the default compilation didn't have python
> bindings included.  What would be the preferred way to get python
> bindings compiled into itk? cswig? or wrapitk?

The CSwig wrappers are the old generation of wrappers, and WrapITK the 
new generation. WrapITK is much more pythonic and easy to use, so if you 
have a choice, you'll be better off with WrapITK than with the CSwig 
wrappers.

> I tried to compile CableSwig by doing a co of the source and place it in
> the InsightToolkit-3.14.0-src/Utilities directory but it failed to
> build. So I built CableSwig on the side and pointed CableSwig_DIR
> variable to where I installed it. Then after much trial and error,
> turning on different cmake flags and recompile itk, I got it to compile.
> I also believe I have the both WRAP_ITK_PYTHON and ITK_CSWIG_PYTHON
> flags set to on.

With ITK 3.14, you should use WrapITK version 0.3.0 hosted on Google 
Code (http://code.google.com/p/wrapitk/). First compile and install ITK 
(without any wrapping option), and then compile and install WrapITK. If 
you are interested in the projects located in wrapitk/ExternalProjects, 
they must be compiled and installed after WrapITK itself.

> At the end, I have these
> itk-3.14.0/vis.Linux-2.6.18-128.1.1.el5.x86_64.gcc-4.1.2.release/lib/InsightToolkit/python
> directory which contains the following files
> InsightToolkit.py  itkbase.py   itkbasicfilters.py  itkdata.py
> itknumerics.py  vxlnumerics.py
> itkalgorithms.py   itkbase.pyc  itkcommon.py        itkio.py
> itktesting.py
> I have PYTHONPATH set to that directory also.
> When I do import itk in python shell, I can't find module named itk.
> Am I missing anything or shall I do import itkbase instead of itk?

With WrapITK, "import itk" does the trick.

HTH,
-- 
Julien


More information about the Insight-users mailing list