[ITK] Query about building ITK on Windows 64-bit with Python Wrapping

Matt McCormick matt.mccormick at kitware.com
Tue Apr 7 01:27:11 EDT 2015


Hello Evan,

After adding this patch [1], I have had success by copying the
generated WrapITK.pth file to the Python Lib/site-packages directory.
Also, the directory containing the ITK .dll files, e.g.
<build-dir>/bin/Release, must be added to the PATH environmental
variable.

Hope this helps,
Matt

[1] http://review.source.kitware.com/#/c/19560/

On Sun, Apr 5, 2015 at 4:56 AM, Evan Kao <tossin at gmail.com> wrote:
> Hello Matt,
>
> I'm using Python 2.7.6.  I'll see whether I have better luck with a
> different build later.
>
> Thanks,
> Evan Kao
>
> On Sat, Apr 4, 2015 at 7:25 PM, Matt McCormick <matt.mccormick at kitware.com>
> wrote:
>>
>> Hi Evan,
>>
>> Thanks for your persistance and sharing your experiences with the list!
>>
>> To answer a previous question, it should not take so long to build the
>> wrapping. Using the Ninja generator, wrapping is built on the
>> dashboard in under 2 hours, including all the tests. To speed things
>> up, try disabling BUILD_TESTING and BUILD_EXAMPLES.  Also parallelize
>> your build as described here [1].
>>
>> What version of Python are you using?
>>
>> Thanks,
>> Matt
>>
>> [1] http://www.kitware.com/blog/home/post/434
>>
>> On Sat, Apr 4, 2015 at 4:19 AM, Evan Kao <tossin at gmail.com> wrote:
>> > Hi itk-users,
>> >
>> > I'm still having a lot of trouble importing ITK into Python.  If I add
>> > the
>> > following paths (specified in WrapITK.pth) to PYTHONPATH:
>> >
>> > ..\lib\Release
>> > ..\Wrapping\Generators\Python\Release
>> >
>> > and ..\bin\Release to PATH, then attempt to import itk, I get the
>> > following
>> > error:
>> >
>> >> Traceback (most recent call last):
>> >>   File "<console>", line 2, in <module>
>> >>   File "L:\git\ITK-build\Wrapping\Generators\Python\Release\itk.py",
>> >> line
>> >> 54, in <module>
>> >>     itkBase.LoadModule(module, thisModule.__dict__)
>> >>   File
>> >> "L:\git\ITK-build\Wrapping\Generators\Python\Release\itkBase.py",
>> >> line 53, in LoadModule
>> >>     swig.__dict__.update(this_module.swig.__dict__)
>> >> AttributeError: 'module' object has no attribute 'swig'
>> >
>> >
>> > If in itkConfig.py I set LazyLoading = False, and attempt to import itk,
>> > I
>> > get:
>> >
>> >> Traceback (most recent call last):
>> >>   File "<stdin>", line 1, in <module>
>> >>   File "L:\git\ITK-build\Wrapping\Generators\Python\Release\itk.py",
>> >> line
>> >> 54, in <module>
>> >>     itkBase.LoadModule(module, thisModule.__dict__)
>> >>   File
>> >> "L:\git\ITK-build\Wrapping\Generators\Python\Release\itkBase.py",
>> >> line 108, in LoadModule
>> >>     LoadModule(dep, namespace)
>> >>   File
>> >> "L:\git\ITK-build\Wrapping\Generators\Python\Release\itkBase.py",
>> >> line 108, in LoadModule
>> >>     LoadModule(dep, namespace)
>> >>   File
>> >> "L:\git\ITK-build\Wrapping\Generators\Python\Release\itkBase.py",
>> >> line 108, in LoadModule
>> >>     LoadModule(dep, namespace)
>> >>   File
>> >> "L:\git\ITK-build\Wrapping\Generators\Python\Release\itkBase.py",
>> >> line 108, in LoadModule
>> >>     LoadModule(dep, namespace)
>> >>   File
>> >> "L:\git\ITK-build\Wrapping\Generators\Python\Release\itkBase.py",
>> >> line 118, in LoadModule
>> >>     module = loader.load(swigModuleName)
>> >>   File
>> >> "L:\git\ITK-build\Wrapping\Generators\Python\Release\itkBase.py",
>> >> line 225, in load
>> >>     fp, pathname, description = imp.find_module(name)
>> >> ImportError: No module named ITKPyBasePython
>> >
>> >
>> > So it seems like it can't find the python modules.  So I tried adding
>> > ..\lib
>> > to the PYTHONPATH and then imported itk and no errors appeared.  However
>> > if
>> > I try instantiating a class, I get:
>> >
>> >> Traceback (most recent call last):
>> >>   File "<stdin>", line 1, in <module>
>> >> TypeError: 'itkTemplate' object is not callable
>> >
>> >
>> > Anybody have any ideas on what's going on?  Or suggestions on how to
>> > proceed?
>> >
>> > Thanks,
>> > Evan Kao
>> >
>> > On Sun, Mar 22, 2015 at 12:19 AM, Evan Kao <tossin at gmail.com> wrote:
>> >>
>> >> Hello Bradley,
>> >>
>> >> Regarding registration, I'm just exploring options right now.  It seems
>> >> like SimpleITK 0.9b is the way to go then.
>> >>
>> >> I still attempted to build ITK 4.8 with python-wrapping on and a few
>> >> additional optional modules that I turned on mainly because they
>> >> sounded
>> >> interesting (ITKConfig.cmake attached for reference) with Visual Studio
>> >> 2013/ver 12.  The build took about 12 hours (is that normal?) and seems
>> >> to
>> >> have mostly succeeded other than a few errors in the optional modules
>> >> (I
>> >> think they were in BridgeNumpy and VariationalRegistration).
>> >>
>> >> However I'm having some trouble using itk in python (same as the one
>> >> described here).  I've tried adding the WrapITK.pth file to
>> >> site-packages as
>> >> well as directly adding both of the paths specified in WrapITK.pth
>> >> directly
>> >> to the PYTHONPATH, but keep getting "AttributeError: 'module' object
>> >> has no
>> >> attribute 'swig' " every time I attempt to use a filter.  Do you know
>> >> how to
>> >> fix the issue?
>> >>
>> >> Thanks,
>> >> Evan Kao
>> >>
>> >> On Sat, Mar 21, 2015 at 8:29 AM, Bradley Lowekamp
>> >> <blowekamp at mail.nih.gov>
>> >> wrote:
>> >>>
>> >>> Hello,
>> >>>
>> >>> WrapITK has recently been upgraded to use CastXML ( clang based ),
>> >>> instead of GCCXML. This appears to now be working MS VS12 ( aka Visual
>> >>> Studio 2013?) windows compiler[1]. This is relatively new and it would
>> >>> be
>> >>> great if you can checkout ITK master and try to build it and report
>> >>> how it
>> >>> works for you. The wiki hasn't been updated with this latest bit of
>> >>> information.
>> >>>
>> >>> However please keep in mind that WrapITK does not contain 100% of ITK
>> >>> and
>> >>> not 100% of Registration. For example it does contain the ITKv3
>> >>> ImageRegistationMethod however it doest not contain the new ITKv4
>> >>> ImageRegistration method or frame work. With effort this thing can be
>> >>> wrapped.
>> >>>
>> >>> If you have to resort to SimpleITK, you will find the binaries for
>> >>> window64 readily available from the nightly dashboard[2]. The best
>> >>> place to
>> >>> check if SimpleITK has the registration methods you need would be the
>> >>> doxygen[3]. It contains the ITKv4 Registration framework, as well as
>> >>> some
>> >>> legacy image registration filter. The frame work is capable of
>> >>> affines,
>> >>> bspline, and displacement transforms and many nice feature of the
>> >>> ITKv4
>> >>> framework.
>> >>>
>> >>> Do you have a specific registration method you are looking to do? or
>> >>> just
>> >>> explore some options?
>> >>>
>> >>> Brad
>> >>>
>> >>> [1] https://open.cdash.org/buildSummary.php?buildid=3738598
>> >>> [2] http://www.itk.org/Wiki/SimpleITK/GettingStarted#Nightly_binaries
>> >>> [3] http://www.itk.org/SimpleITKDoxygen/html/classes.html
>> >>>
>> >>> On Mar 21, 2015, at 3:17 AM, Evan Kao <tossin at gmail.com> wrote:
>> >>>
>> >>> Hello itk-users,
>> >>>
>> >>> I'd like to use ITK features in python that don't seem to be
>> >>> implemented
>> >>> in the latest stable release of SimpleITK, like image registration and
>> >>> quadmesh filters.  However, looking around the internet, several
>> >>> sources
>> >>> (like the Wiki, this thread from about 5 months ago, or this site)
>> >>> seem to
>> >>> suggest building WrapITK isn't possible on a 64-bit machine due to
>> >>> conflict
>> >>> between GCCXML and any Visual Studio beyond 2008 (and VS2008 64-bit
>> >>> apparently only comes with the professional edition, which I'm not
>> >>> even sure
>> >>> is available or worth obtaining).  The Wiki also suggests mingw64 is
>> >>> also
>> >>> not viable.  Is this still the case?   Is there anyway to use ITK with
>> >>> python on a 64-bit machine?
>> >>>
>> >>> If I have to resort to the latest nightly binary of SimpleITK for
>> >>> image
>> >>> registration, does it include all the registration methods available
>> >>> in ITK?
>> >>>
>> >>> Thanks,
>> >>> Evan Kao
>> >>> _______________________________________________
>> >>> Community mailing list
>> >>> Community at itk.org
>> >>> http://public.kitware.com/mailman/listinfo/community
>> >>>
>> >>>
>> >>
>> >
>> >
>> > _______________________________________________
>> > Community mailing list
>> > Community at itk.org
>> > http://public.kitware.com/mailman/listinfo/community
>> >
>
>


More information about the Community mailing list