[ITK] [ITK-users] ITK 4.6.0 Python Wrapping (swig?) problem

Michka Popoff michkapopoff at gmail.com
Tue Sep 30 09:51:06 EDT 2014


Just writing this down for the list archives

Sami, thank you very much for all the informations.
I updated an created a new page, for Fedora and Ubuntu, with all the details.

http://www.itk.org/Wiki/ITK/WrapITKInstallLinux

For the moment this page is somewhat hidden, because you need to click 3-4 links through the FAQ and multiple pages to get to it.
I will maybe reorganize the wiki a little bit to move the installation procedures to the front page.

Thanks again

Michka

On 30 sept. 2014, at 15:14, Michka Popoff <michkapopoff at gmail.com> wrote:

> Would it be possible for you to write this down for me, so I can update the guide on the wiki ?
> 
> Michka
> 
> On 30 sept. 2014, at 14:51, Sami Koho <sami.koho at gmail.com> wrote:
> 
>> Thank you Michka! The solution was in the ldconfig file creation:
>> 
>>> ITK will install by default in /usr/local/lib. Now, you have to tell the system that the files have been installed here.
>>> cd /etc/ld.so.conf.d/
>>> add a file called itk-46.conf, which should contain only one line: /usr/local/lib
>>> ldconfig # tells the system to read the files in ld.so.conf.d
>> 
>> On Ubuntu 14 the Python directory configuration is a bit different than in the Fedora guide:
>> 
>>> /Path to a program.
>>> PYTHON_EXECUTABLE:FILEPATH=/usr/bin/python
>>> 
>>> //Path to a file.
>>> PYTHON_INCLUDE_DIR:PATH=/usr/include/python2.7
>>> 
>>> //Path to a file.
>>> PYTHON_INCLUDE_DIR2:PATH=/usr/include/x86_64-linux-gnu/python2.7
>>> 
>>> //Path to a library.
>>> PYTHON_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
>>> 
>>> //Path to a library.
>>> PYTHON_LIBRARY_DEBUG:FILEPATH=PYTHON_LIBRARY_DEBUG-NOTFOUND
>>> 
>>> //Directory where the arrayobject.h header file can be found. This
>>> // file is part of the numarray package
>>> PYTHON_NUMARRAY_INCLUDE_DIR:PATH=/usr/lib/python2.7/dist-packages/numpy/core/include/numpy
>>> 
>>> //Python site-packages directory to install a .pth file pointing
>>> // at WrapITK Python modules.
>>> PY_SITE_PACKAGES_PATH:PATH=/usr/lib/python2.7/dist-packages
>> 
>> 
>> Best,
>> 
>> Sami
>> 
>> On Sep 30, 2014, at 14:03, Michka Popoff <michkapopoff at gmail.com> wrote:
>> 
>>> Hi
>>> 
>>> once ITK is compiled, there is no more need for Swig at runtime.
>>> 
>>> For the syntax, you should use the new wrapping syntax.
>>> Look at how it is done in this example, at the end there is python code [1]
>>> 
>>> I would recommend you not to use system swig, this is mostly an option for people wanting to play around with external versions of swig.
>>> If you want to be sure it works, just set ITK_USE_SYSTEM_SWIG=OFF. ITK will download, compile and use an internal swig.
>>> You can find a detailed tutorial for the installation here : http://www.itk.org/Wiki/ITK/WrapITKInstallFedora
>>> 
>>> The tutorial should work for Ubuntu 14, I never tried but one user reported being able to install ITK wrappings with this tutorial.
>>> 
>>> [1] http://itk.org/ITKExamples/src/Filtering/AnisotropicSmoothing/ComputeCurvatureAnisotropicDiffusion/Documentation.html
>>> 
>>> Michka
>>> 
>>> On 30 sept. 2014, at 12:51, Sami Koho <sakoho at utu.fi> wrote:
>>> 
>>>> Hello,
>>>> 
>>>> this week I tried to upgrade my ITK installation on my Ubuntu 14.04 (64 bit) to the 4.6.0 release version, as it promised much improved Python wrapping. I had previously been using some pre-4.6 build from GIT. The library compiles fine, but now the Python wrapping does not work on my computer.
>>>> 
>>>> I am able to load itk in Python, but every time I try to execute anything, the following error appears:
>>>> 
>>>>> <ipython-input-12-8e289c4078ab> in <module>()
>>>>> ----> 1 reader = itk.ImageFileReader.IUC3.New()
>>>>> 
>>>>> /usr/local/lib/ITK-4.6/Python/itkLazy.py in __getattribute__(self, attr)
>>>>>    40             module = self.__lazy_attributes[attr]
>>>>>    41             namespace = {}
>>>>> ---> 42             itkBase.LoadModule(module, namespace)
>>>>>    43             # Load into 'namespace' first, then self.__dict__ (via setattr) to
>>>>>    44             # prevent the warnings about overwriting the 'NotLoaded' values
>>>>> 
>>>>> /usr/local/lib/ITK-4.6/Python/itkBase.py in LoadModule(name, namespace)
>>>>>    51         if namespace is not None:
>>>>>    52             swig = namespace.setdefault('swig', imp.new_module('swig'))
>>>>> ---> 53 swig.__dict__.update(this_module.swig.__dict__)
>>>>>    54
>>>>>    55             # don't worry about overwriting the symbols in namespace -- any
>>>>> 
>>>>> AttributeError: 'module' object has no attribute 'swig'
>>>> 
>>>> I have had this problem before, but previously on Ubuntu I solved it by selecting USE SYSTEM SWIG in CMAKE before compiling. Now, as the version 4.6.0 requires a newer version of swig, this does not work. As a further detail, if I try to manually insert a command, for example in iPython,  tab-completion works until the module names e.g. itk.ImageFileReader, but then stops. It seems that the swig can not be found or is not working properly.
>>>> 
>>>> Should I manually set a path to swig? Or is something else wrong instead?
>>>> 
>>>> I have installed ITK in the default path /usr/local/lib, as can be seen from the example.
>>>> 
>>>> Best,
>>>> 
>>>> Sami
>>> 
>>> _____________________________________
>>> 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
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140930/0ddcd2bc/attachment-0002.html>
-------------- next part --------------
_____________________________________
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 Community mailing list