Hello,
I’m having some trouble using the ITK python wrapping functionality. I’m trying to work through the basic python examples but I’m unable to import ITK even after copying the WrapITK.pth file to my site-packages directory. I can import ITK if I manually add “/Wrapping/Generators/Python/” to the path. If I do that I receive an error when I try to use basic modules (I’ve tested itk.imread and itk.Image so far and receive the same error for both):
C:\research\itk\Wrapping\Generators\Python\Release\itkBase.py in LoadModule (name, namespace)
59 if namespace is not None :
60 swig = namespace . setdefault ( ‘swig’ , { } ) —>
61 swig . update ( this_module . swig )
62
63 # don’t worry about overwriting the symbols in namespace – any **
AttributeError** : module ‘itk.ITKIOImageBasePython’ has no attribute ‘swig’
Incase it’s helpful, here’s some background:
I compiled ITK 5.1.1 from source following the instructions in the software guide. ITK_WRAP_PYTHON was enabled, but I did not have the other variables that the guide mentioned after configuring multiple times: PYTHON INCLUDE DIR, PYTHON LIBRARY, and PYTHON EXECUTABLE. Even so, everything compiled without error. I’m using Windows 10 and Visual Studio 2019.
When I went to copy the WrapITK.pth to my site-packages directory, I found that it wasn’t in the Wrapping\Generators\Python\ folder as specified in the install guide. I did find it in \Wrapping\Generators\Python\Release and copied it to the site-packages directory.
I’ve tried installing swig separately and enabling the use system swig option, but that didn’t help. I’ve also tried compiling with and without building the shared libraries.
I’m very stumped on this one, and I would appreciate any suggestions on what to try next.