# swig error after upgrading to 5.0

**URL:** https://discourse.itk.org/t/swig-error-after-upgrading-to-5-0/1933
**Category:** Engineering
**Created:** [June 1, 2019, 5:59am UTC](https://discourse.itk.org/t/swig-error-after-upgrading-to-5-0/1933 "2019-06-01T05:59:35Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Jianxu\_Chen](https://discourse.itk.org/user_avatar/discourse.itk.org/jianxu_chen/32/809_2.png) [@Jianxu\_Chen](https://discourse.itk.org/u/Jianxu_Chen)
#### Post date: [June 1, 2019, 5:59am UTC](https://discourse.itk.org/t/swig-error-after-upgrading-to-5-0/1933/1 "2019-06-01T05:59:35Z")

</div>

```auto
itk_seed = itk.GetImageFromArray(init_levelset.astype(np.float32))

InternalImageType = itk.Image[itk.F, 3]

geodesicActiveContour = itk.GeodesicActiveContourLevelSetImageFilter[InternalImageType,InternalImageType,itk.F].New(itk_seed)
geodesicActiveContour.SetPropagationScaling(10.0)
geodesicActiveContour.SetCurvatureScaling(1.0)
geodesicActiveContour.SetAdvectionScaling(1.0)
geodesicActiveContour.SetMaximumRMSError(0.02)
geodesicActiveContour.SetNumberOfIterations(60)
geodesicActiveContour.SetFeatureImage(itk_img_sigmoid)
geodesicActiveContour.Update()

itk_GAC = geodesicActiveContour.GetOutput()

```

I used this piece of code for a 3d level set segmentation step. It worked okay previously. After updating to 5.0 today, I got the following error:

AttributeError Traceback (most recent call last)  
 in   
5 InternalImageType = itk.Image[itk.F, 3]  
6  
----\> 7 geodesicActiveContour = itk.GeodesicActiveContourLevelSetImageFilter[InternalImageType,InternalImageType,itk.F].New(itk\_seed)  
8 geodesicActiveContour.SetPropagationScaling(10.0)  
9 geodesicActiveContour.SetCurvatureScaling(1.0)

c:\users\jianxuc\appdata\local\continuum\anaconda3\envs\segmenter\lib\site-packages\itkLazy.py in **getattribute** (self, attr)  
42 module = self.\_\_belong\_lazy\_attributes[attr]  
43 namespace = {}  
—\> 44 itkBase.LoadModule(module, namespace)  
45 for k, v in namespace.items():  
46 setattr(self, k, v)

c:\users\jianxuc\appdata\local\continuum\anaconda3\envs\segmenter\lib\site-packages\itkBase.py in LoadModule(name, namespace)  
61 else:  
62 swig = namespace.setdefault(‘swig’, imp.new\_module(‘swig’))  
—\> 63 swig. **dict**.update(this\_module.swig. **dict** )  
64  
65 # don’t worry about overwriting the symbols in namespace – any

AttributeError: module ‘ITKLevelSets’ has no attribute ‘swig’

BTW, is there a more detailed documentation about new pythonic interface? For example, I want to use itk.GeodesicActiveContourLevelSetImageFilter. What is the pythonic way to use it?

Many thanks,  
Jianxu

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [June 26, 2019, 8:42pm UTC](https://discourse.itk.org/t/swig-error-after-upgrading-to-5-0/1933/2 "2019-06-26T20:42:11Z")

</div>

Hi Jianxu,

The initial release of the ITK 5.0.0 Python packages contained a bug that may be the source of your problem. Please try

```sh
python -m pip install --upgrade itk

```

to install the `itk-5.0.0.post1` Python package.

> [@Jianxu\_Chen](#):
>
> BTW, is there a more detailed documentation about new pythonic interface? For example, I want to use itk.GeodesicActiveContourLevelSetImageFilter. What is the pythonic way to use it?

The code can replace by this single call:

```python
itk_GAC = itk.geodesic_active_contour_level_set_image_filter(itk_seed,
        feature_image=itk_img_sigmoid,
        propagation_scaling=10.0,
        curvature_scaling=1.0,
        advection_scaling=1.0,
        MaximumRMSError=0.02,
        number_of_iterations=60)

```

Notice than the corresponding API is easily implied, we can use snake case, we do not need to specify the filter type, and a single call replaces instantiating the filter, setting its parameters, calling `.Update()`, and calling `.GetOutput()`.

An overview of the new interface can be found in the [ITK 5.0 Beta 1: Pythonic Interface](https://discourse.itk.org/t/itk-5-0-beta-1-pythonic-interface/1271) release announcement.

@hjmjohnson is leading a major update to the [ITK Sphinx Examples](https://github.com/InsightSoftwareConsortium/ITKExamples). This is currently a work in progress, but the plan to improve these to use the new interface as the dust settles.
