# Trouble building ITK python wrapping

**URL:** <https://discourse.slicer.org/t/trouble-building-itk-python-wrapping/21729>\
**Category:** Development\
**Tags:** build, itk, itk-python\
**Created:** [February 1, 2022, 11:43am UTC](https://discourse.slicer.org/t/trouble-building-itk-python-wrapping/21729 "2022-02-01T11:43:20Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ebrahim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ebrahim/32/13403_2.png) [@ebrahim](https://discourse.slicer.org/u/ebrahim)\
**Post date:** [February 1, 2022, 11:43am UTC](https://discourse.slicer.org/t/trouble-building-itk-python-wrapping/21729/1 "2022-02-01T11:43:20Z")

</div>

I want to include ITK python wrapping in my Slicer build, but building fails when I turn on `Slicer_BUILD_ITKPython`, with the following error in the make output

```nohighlight
...
-- ITKPyUtils: Creating itkPyCommand submodule.
-- ITKPyUtils: Creating itkPyImageFilter submodule.
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
_vtk_lib_include_dirs
   used as include directory in directory /home/ebrahim/Slicer-SuperBuild-Debug/ITK/Modules/Bridge/VtkGlue/wrapping
   used as include directory in directory /home/ebrahim/Slicer-SuperBuild-Debug/ITK/Modules/Bridge/VtkGlue/wrapping
  ... <more of the same message>
   used as include directory in directory /home/ebrahim/Slicer-SuperBuild-Debug/ITK/Modules/Bridge/VtkGlue/wrapping
-- Configuring incomplete, errors occurred!

```

I see the variable `_vtk_lib_include_dirs` getting assigned [here in ITK](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Bridge/VtkGlue/wrapping/CMakeLists.txt), but I don’t really know what’s going on. Not sure if this is a Slicer issue or an ITK issue. Any ideas?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 2, 2022, 2:56am UTC](https://discourse.slicer.org/t/trouble-building-itk-python-wrapping/21729/2 "2022-02-02T02:56:29Z")

</div>

Slicer passes VTK\_DIR to ITK [here](https://github.com/Slicer/Slicer/blob/1513644e124f19d128d49e98d7e7d979f5b905f1/SuperBuild/External_ITK.cmake#L160), which should be sufficient for ITK to configure ITKVTKGlue.

@thewtex do you have any idea what can go wrong?

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [February 2, 2022, 3:43am UTC](https://discourse.slicer.org/t/trouble-building-itk-python-wrapping/21729/3 "2022-02-02T03:43:27Z")

</div>

Thanks for the report. I will have a look and report back shortly.

---

<div class="post-metadata">

**Author:** ![thewtex](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/thewtex/32/32_2.png) [@thewtex](https://discourse.slicer.org/u/thewtex)\
**Post date:** [February 2, 2022, 3:35pm UTC](https://discourse.slicer.org/t/trouble-building-itk-python-wrapping/21729/4 "2022-02-02T15:35:42Z")

</div>

> <https://github.com/Slicer/Slicer/blob/1513644e124f19d128d49e98d7e7d979f5b905f1/SuperBuild/External_ITK.cmake#L39>

I would recommend updating to ITK `v5.3rc03`. VTK changes its CMake configuration often. There have been updates.

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [February 2, 2022, 3:53pm UTC](https://discourse.slicer.org/t/trouble-building-itk-python-wrapping/21729/5 "2022-02-02T15:53:08Z")

</div>

Here is work already in progress to use most recent ITK. This branch could be used for testing the ITK python wrapping

> <https://github.com/Slicer/Slicer/pull/5954>
>
> This is part of work for #5673.
> 
> C++14 is the new minimum with CMake 3.16.3 as… set by ITK 5.3 requirements (https://github.com/InsightSoftwareConsortium/ITK/blob/v5.3rc01/Documentation/SupportedCompilers.md).
> 
> This will enable future GrowCut remote ITK module work as @dzenanz was beginning in #5807.

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [February 2, 2022, 4:34pm UTC](https://discourse.slicer.org/t/trouble-building-itk-python-wrapping/21729/6 "2022-02-02T16:34:50Z")

</div>

Note this previous attempt linked below of me trying to build ITK python. Some discussion was about `pip install itk` as an easier option for Slicer instead of changing Slicer to build ITK python wrapping as part of the nightly build process.

> [@Build error when building ITKPython](https://discourse.slicer.org/t/build-error-when-building-itkpython/15302):
>
> With Slicer\_BUILD\_ITKPython and Slicer\_INSTALL\_ITKPython turned on and using CMake 3.18.4 and latest Slicer master I get some errors during the wrapping process. Has anyone successfully built ITKPython recently? I was looking into turning on ITK python support as a default in Slicer since it has matured in the past year and half. This would support future python development using import itk instead of relying on SimpleITK when using python. This seems to be the preferred trend to support more …

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [February 2, 2022, 7:21pm UTC](https://discourse.slicer.org/t/trouble-building-itk-python-wrapping/21729/7 "2022-02-02T19:21:37Z")

</div>

A post was split to a new topic: [Addressing issue with “pip install itk”](https://discourse.slicer.org/t/addressing-issue-with-pip-install-itk/21763)

---

<div class="post-metadata">

**Author:** ![ebrahim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ebrahim/32/13403_2.png) [@ebrahim](https://discourse.slicer.org/u/ebrahim)\
**Post date:** [February 2, 2022, 4:47pm UTC](https://discourse.slicer.org/t/trouble-building-itk-python-wrapping/21729/8 "2022-02-02T16:47:36Z")

</div>

Thanks for pointing me to this PR!  
I will try building off this branch and report back.

---

<div class="post-metadata">

**Author:** ![ebrahim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ebrahim/32/13403_2.png) [@ebrahim](https://discourse.slicer.org/u/ebrahim)\
**Post date:** [February 2, 2022, 9:50pm UTC](https://discourse.slicer.org/t/trouble-building-itk-python-wrapping/21729/9 "2022-02-02T21:50:42Z")

</div>

With that branch I ended up with the following error during build on linux:

```nohighlight
[100%] Generating ../../itkImageToVTKImageFilter.xml
In file included from /path/to/superbuild/ITK-build/Wrapping/itkImageToVTKImageFilter.cxx:16:
/path/to/superbuild/ITK/Modules/Bridge/VtkGlue/include/itkImageToVTKImageFilter.h:22:10: fatal error: 'vtkImageImport.h' file not found
#include "vtkImageImport.h"
         ^ ~~~~~~~~~~~~~~~~~
1 error generated.
make[5]: *** [Wrapping/Modules/ITKVtkGlue/CMakeFiles/ITKVtkGlueCastXML.dir/build.make:65: Wrapping/itkImageToVTKImageFilter.xml] Error 1
make[4]: *** [CMakeFiles/Makefile2:36492: Wrapping/Modules/ITKVtkGlue/CMakeFiles/ITKVtkGlueCastXML.dir/all] Error 2
make[3]: *** [Makefile:152: all] Error 2
make[2]: *** [slicersources-build/CMakeFiles/ITK.dir/build.make:118: slicersources-build/ITK-prefix/src/ITK-stamp/ITK-build] Error 2
make[1]: *** [CMakeFiles/Makefile2:877: slicersources-build/CMakeFiles/ITK.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

```

EDIT: I should add that I was trying this with a Slicer Custom App, not with vanilla Slicer. So the issue may be related to the way in which I included the new branch. Perhaps I omitted a needed change in my top level cmake file.

I’ll continue digging into this.

---

<div class="post-metadata">

**Author:** ![ebrahim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ebrahim/32/13403_2.png) [@ebrahim](https://discourse.slicer.org/u/ebrahim)\
**Post date:** [February 3, 2022, 11:44pm UTC](https://discourse.slicer.org/t/trouble-building-itk-python-wrapping/21729/10 "2022-02-03T23:44:41Z")

</div>

Update: Same error with vanilla Slicer.
