# itk.ImageToVTKImageFilter crashing Python

**URL:** <https://discourse.itk.org/t/itk-imagetovtkimagefilter-crashing-python/2018>\
**Category:** Algorithms\
**Tags:** python\
**Created:** [July 9, 2019, 2:03am UTC](https://discourse.itk.org/t/itk-imagetovtkimagefilter-crashing-python/2018 "2019-07-09T02:03:50Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Phong\_Tran](https://discourse.itk.org/user_avatar/discourse.itk.org/phong_tran/32/1024_2.png) [@Phong\_Tran](https://discourse.itk.org/u/Phong_Tran)\
**Post date:** [October 19, 2019, 7:51am UTC](https://discourse.itk.org/t/itk-imagetovtkimagefilter-crashing-python/2018/7 "2019-10-19T07:51:52Z")

</div>

After several gooling and research on code, I was able to use itk.ImageToVTKImageFilter by using my own built ITK source code. For those whose are new comer like me, hope this help you. First of all, I compile source code of ITK release version ([ITK Release](https://github.com/InsightSoftwareConsortium/ITK/releases/download/v5.0.1/InsightToolkit-5.0.1.tar.gz)). Note that I tried the ITK Github ([ITK Github](https://github.com/InsightSoftwareConsortium/ITK)), but did not succeed. So I recommend you to compile with Release version. For VTK source code, I also used the the Release version 8.2, not the Github code. The next step I did is to enable the ITK VTK Glue in CMakeCache to ON,adn ITK\_WRAP\_PYTHON to ON. like this:

> ╭─phongtd@nguyenth ~/workingspace/InsightToolkit-5.0.1/build\_other  
> ╰─$ grep Module\_ITKVtkGlue CMakeCache.txt  
> **Module\_ITKVtkGlue:BOOL=ON**  
> //ADVANCED property for variable: Module\_ITKVtkGlue  
> Module\_ITKVtkGlue-ADVANCED:INTERNAL=1

> ╭─phongtd@nguyenth ~/workingspace/InsightToolkit-5.0.1/build\_other  
> ╰─$ grep PYTHON CMakeCache.txt  
> **ITK\_WRAP\_PYTHON:BOOL=ON**  
> ITK\_WRAP\_PYTHON\_LEGACY:BOOL=ON  
> PYTHON\_EXECUTABLE:FILEPATH=/usr/bin/python  
> PYTHON\_INCLUDE\_DIR:PATH=/usr/include/python3.6m  
> PYTHON\_LIBRARY:FILEPATH=/usr/lib/x86\_64-linux-gnu/libpython3.6m.so  
> PYTHON\_LIBRARY\_DEBUG:FILEPATH=PYTHON\_LIBRARY\_DEBUG-NOTFOUND  
> ITK\_WRAP\_PYTHON\_BINARY\_DIR:INTERNAL=/home/phongtd/workingspace/InsightToolkit-5.0.1/build\_other/Wrapping/Generators/Python  
> ITK\_WRAP\_PYTHON\_SOURCE\_DIR:INTERNAL=/home/phongtd/workingspace/InsightToolkit-5.0.1/Wrapping/Generators/Python  
> //ADVANCED property for variable: PYTHON\_EXECUTABLE  
> PYTHON\_EXECUTABLE-ADVANCED:INTERNAL=1  
> //ADVANCED property for variable: PYTHON\_INCLUDE\_DIR  
> PYTHON\_INCLUDE\_DIR-ADVANCED:INTERNAL=1  
> //ADVANCED property for variable: PYTHON\_LIBRARY  
> PYTHON\_LIBRARY-ADVANCED:INTERNAL=1  
> //ADVANCED property for variable: PYTHON\_LIBRARY\_DEBUG  
> PYTHON\_LIBRARY\_DEBUG-ADVANCED:INTERNAL=1

On this step, I encountered many issues which I asked on the thread [https://discourse.itk.org/t/itk-python-wrapping-error-void-value-not-ignored-as-it-ought-to-be/948/10](https://discourse.itk.org/t/itk-python-wrapping-error-void-value-not-ignored-as-it-ought-to-be/948/10). Do the same thing on that thead you can compile the ITK with Python enabled.

The last step is to run the example. Before doing that, I set the PYTHONPATH variable to point to my ITK build like this:

> export PYTHONPATH=/home/phongtd/workingspace/InsightToolkit-5.0.1/build\_other/Wrapping/Generators/Python:$PYTHONPATH

And finally, the work is done without any issues.

---

_[View the full topic](https://discourse.itk.org/t/itk-imagetovtkimagefilter-crashing-python/2018)._
