[ITK-users] ITK Python wrapping

Matt McCormick matt.mccormick at kitware.com
Sun Aug 23 16:53:27 EDT 2015


Hi Fabio,

There is information in The ITK Software Guide, but we could improve
it based on your experiences.


In the ITK "lib" directory, or one of its subdirectories, there should
be a _ITKPyBasePython.pyd.  This is the file that the error message
indicates it cannot find. First, check that it exists.  Next, check
that the folder it lives in is listed in the WrapITK.pth file and that
the WrapITK.pth file was added to the Libs/site-packages directory of
your virtualenv.


Some more information regarding the other questions:

- Swig is automatically downloaded when building ITK Python wrapping,
but it is no longer needed after the wrappers are built.

- There should not be CastXML errors, and if there were, that may be a
problem.  What are the errors?

- Windows cannot create symbolic links -- files must be copied
instead.  We can simplify the documentation to state that the
WrapITK.pth file should be copied on all platforms.  Where was the
instruction to create a symbolic link?


Please let us know how it goes,
Matt



On Sat, Aug 22, 2015 at 3:02 AM, D'Isidoro  Fabio <fisidoro at ethz.ch> wrote:
> I am a newbie, trying to use ITK with Python wrapping on Windows 7. Using
> the short ITKSoftwareGuide, but could not find a comprehensive guide to use
> Python wrappers for dummies.
>
>
>
> My problem is: I can’t make the Python wrapping work. I can import itk with
> no errors when running Python in the new virtual environment configured
> inside my ITK build directory. But:
>
>
>
> -        As in this example
> (http://www.vtk.org/Wiki/ITK/Release_4/Wrapping/Examples) , I get no error
> for “PixelType = itk.UC” but when trying “ImageType = itk.Image[ImageType,
> 2]” I get the error1 in attachment (no module named _ITKPyBasePython …
> something related to SWIG, that I don’t have). Do I need to install Swig?
> (In a similar question in the iTK Wiki page the answer was: you will need
> the ITKv4 wrapping to use this example … ?)
>
>
>
> -        Seemingly, in the new virtual env I try to run “python
> ImageRegistration3.py BrainProtonDensitySliceBorder20.png
> BrainProtonDensitySliceShifted13x17y.png output_image” in attachment
> (modified from the Examples folder with proper inputs), which starts with
> “import itk ; fixedImageReader  = itkImageFileReaderF2_New()” I get the
> error “name itkImageFileReaderF2_New is not defined”.
>
>
>
> Lacking of a guide, I actually have no clue about how to use Python wrappers
> in general. Is there any guide that I could follow?
>
>
>
> Useful info:
>
>
>
> I have successfully built ITK with Cmake with the ITK-WRAP-PYTHON option.
> The build had some failures related to the CastXML tool… could this be a
> problem?
>
>
>
> I configured a new Python virtual environment within my ITK build directory.
>
>
>
> I copied/pasted the file
> /path/to/myITK_wrapped/Wrapping/Generators/Python/Debug/WrapITK.pth into
> wrap_itk_venv/Lib/site-packages. Is that correct to generate a symbolic link
> in Windows?
>
>
>
> I also added path/to/myITK_wrapped,  path/to/myITK_wrapped/bin and
> path/to/myITK_wrapped/bin/Debug in my user env variable PATH
>
>
>
> Thank you for your help.
>
>
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-users
>


More information about the Insight-users mailing list