# ITK Python Wrapping error: void value not ignored as it ought to be

**URL:** <https://discourse.itk.org/t/itk-python-wrapping-error-void-value-not-ignored-as-it-ought-to-be/948>\
**Category:** Engineering\
**Tags:** python\
**Created:** [May 24, 2018, 10:00pm UTC](https://discourse.itk.org/t/itk-python-wrapping-error-void-value-not-ignored-as-it-ought-to-be/948 "2018-05-24T22:00:24Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![phcerdan](https://discourse.itk.org/user_avatar/discourse.itk.org/phcerdan/32/286_2.png) [@phcerdan](https://discourse.itk.org/u/phcerdan)\
**Post date:** [May 24, 2018, 10:00pm UTC](https://discourse.itk.org/t/itk-python-wrapping-error-void-value-not-ignored-as-it-ought-to-be/948/1 "2018-05-24T22:00:25Z")

</div>

Building in debug mode from master.

First time encountered here:

```auto
Wrapping/Generators/Python/PyBase/ITKPyBasePython.cpp: In function ‘void init_ITKPyBasePython()’:
Wrapping/Generators/Python/PyBase/ITKPyBasePython.cpp:3857:52: error: void value not ignored as it ought to be
     PyObject * pyBaseModule = PyInit__pyBasePython();

```

And also later:

```auto
Wrapping/Modules/ITKCommon/ITKCommonPython.cpp: In function ‘void init_ITKCommonPython()’:
Wrapping/Modules/ITKCommon/ITKCommonPython.cpp:3925:66: error: void value not ignored as it ought to be
     PyObject * itkFixedArrayModule = PyInit__itkFixedArrayPython();
                                                                  ^
Wrapping/Modules/ITKCommon/ITKCommonPython.cpp:3935:58: error: void value not ignored as it ought to be
     PyObject * itkVectorModule = PyInit__itkVectorPython();
                                                          ^
Wrapping/Modules/ITKCommon/ITKCommonPython.cpp:3945:76: error: void value not ignored as it ought to be
     PyObject * itkCovariantVectorModule = PyInit__itkCovariantVectorPython();
                                                                            ^
Wrapping/Modules/ITKCommon/ITKCommonPython.cpp:3955:56: error: void value not ignored as it ought to be
     PyObject * itkPointModule = PyInit__itkPointPython();

```

Has anyone faced this before? Thanks!

---

<div class="post-metadata">

**Author:** ![phcerdan](https://discourse.itk.org/user_avatar/discourse.itk.org/phcerdan/32/286_2.png) [@phcerdan](https://discourse.itk.org/u/phcerdan)\
**Post date:** [May 24, 2018, 11:02pm UTC](https://discourse.itk.org/t/itk-python-wrapping-error-void-value-not-ignored-as-it-ought-to-be/948/2 "2018-05-24T23:02:51Z")

</div>

Issue found. I was linking to a VTK which was using python2.7, instead of python3.6.

thanks to @jcfr for help.

---

<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 12, 2019, 5:04pm UTC](https://discourse.itk.org/t/itk-python-wrapping-error-void-value-not-ignored-as-it-ought-to-be/948/3 "2019-10-12T17:04:51Z")

</div>

Hi @phcerdan,  
I built VTK with Python version 3.6. However, ITK still throws such above exception. Do you know what setting in ITK to make it use python version 3.6 instead ? Seems like my ITK is still using Python 2.7

---

<div class="post-metadata">

**Author:** ![phcerdan](https://discourse.itk.org/user_avatar/discourse.itk.org/phcerdan/32/286_2.png) [@phcerdan](https://discourse.itk.org/u/phcerdan)\
**Post date:** [October 14, 2019, 7:35am UTC](https://discourse.itk.org/t/itk-python-wrapping-error-void-value-not-ignored-as-it-ought-to-be/948/4 "2019-10-14T07:35:10Z")

</div>

> [@Phong\_Tran](#):
>
> Do you know what setting in ITK to make it use python version 3.6 instead

I guess you can use the CMake option `cmake -DPYTHON_EXECUTABLE:PATH=/path/bin/python3 ../ITK-source`

In your case, if you have built VTK with python3.6, do the the same with ITK in a fresh build.

---

<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 15, 2019, 3:37pm UTC](https://discourse.itk.org/t/itk-python-wrapping-error-void-value-not-ignored-as-it-ought-to-be/948/5 "2019-10-15T15:37:45Z")

</div>

Yes, my python is in version 3.6  
phtran@X230:~/workingspace/InsightToolkit-5.0.1/build$ grep PYTHON\_EXECUTABLE CMakeCache.txt  
PYTHON\_EXECUTABLE:FILEPATH=/usr/bin/python  
//ADVANCED property for variable: PYTHON\_EXECUTABLE  
PYTHON\_EXECUTABLE-ADVANCED:INTERNAL=1  
phtran@X230:~/workingspace/InsightToolkit-5.0.1/build$ python --version  
Python 3.6.8

But I still got errors:  
/home/phtran/workingspace/InsightToolkit-5.0.1/build/Wrapping/Generators/Python/PyBase/ITKPyBasePython.cpp: In function ‘void init\_ITKPyBasePython()’:  
/home/phtran/workingspace/InsightToolkit-5.0.1/build/Wrapping/Generators/Python/PyBase/ITKPyBasePython.cpp:3864:52: error: void value not ignored as it ought to be  
PyObject \* pyBaseModule = PyInit\_\_pyBasePython();

---

<div class="post-metadata">

**Author:** ![phcerdan](https://discourse.itk.org/user_avatar/discourse.itk.org/phcerdan/32/286_2.png) [@phcerdan](https://discourse.itk.org/u/phcerdan)\
**Post date:** [October 15, 2019, 7:16pm UTC](https://discourse.itk.org/t/itk-python-wrapping-error-void-value-not-ignored-as-it-ought-to-be/948/6 "2019-10-15T19:16:53Z")

</div>

Just to be sure, what is the result of the following bash command?

```
which python
```

---

<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 16, 2019, 3:12pm UTC](https://discourse.itk.org/t/itk-python-wrapping-error-void-value-not-ignored-as-it-ought-to-be/948/7 "2019-10-16T15:12:41Z")

</div>

Hi Pablo,  
It is:  
phtran@X230:~$ which python  
/usr/bin/python

---

<div class="post-metadata">

**Author:** ![phcerdan](https://discourse.itk.org/user_avatar/discourse.itk.org/phcerdan/32/286_2.png) [@phcerdan](https://discourse.itk.org/u/phcerdan)\
**Post date:** [October 16, 2019, 3:38pm UTC](https://discourse.itk.org/t/itk-python-wrapping-error-void-value-not-ignored-as-it-ought-to-be/948/8 "2019-10-16T15:38:04Z")

</div>

Not sure then @Phong_Tran. Have you tried with a complete fresh build of ITK? i.e removing the build folder completely.

---

<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:** [October 16, 2019, 9:03pm UTC](https://discourse.itk.org/t/itk-python-wrapping-error-void-value-not-ignored-as-it-ought-to-be/948/9 "2019-10-16T21:03:16Z")

</div>

The `PYTHON_EXECUTABLE` _CMakeCache.txt_ variable is important, as @phcerdan.

Other _CMakeCache.txt_ variables to check:

- `PYTHON_INCLUDE_DIR`
- `PYTHON_LIBRARY`

These should correspond to the `PYTHON_EXECUTABLE`.

---

<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 17, 2019, 9:23am UTC](https://discourse.itk.org/t/itk-python-wrapping-error-void-value-not-ignored-as-it-ought-to-be/948/10 "2019-10-17T09:23:25Z")

</div>

I tried to change the variable : PYTHON\_LIBRARY from FILEPATH TO PATH as below:  
From: PYTHON\_LIBRARY:FILEPATH=/usr/lib/x86\_64-linux-gnu/libpython3.6m.so  
To: PYTHON\_LIBRARY:PATH=/usr/lib/python3.6

I dont get the above errors, however, I get the other errors:

> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyObject\_Hash’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyObject\_GetBuffer’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyObject\_Repr’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyExc\_ValueError’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyLong\_AsLong’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyBool\_Type’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyObject\_GetAttr’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyExc\_KeyError’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘\_Py\_TrueStruct’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyNumber\_And’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyTuple\_Pack’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyUnicode\_GetLength’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘Py\_ReprLeave’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘\_Py\_HashPointer’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyObject\_Str’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyObject\_GetAttrString’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyModule\_Type’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyErr\_Restore’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyType\_IsSubtype’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyModule\_GetDict’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyNumber\_Power’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyNumber\_Index’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyUnicode\_InternFromString’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyTuple\_New’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyNumber\_Divmod’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyUnicode\_GetSize’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyExc\_KeyboardInterrupt’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘\_Py\_NoneStruct’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyExc\_AttributeError’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyNumber\_Float’  
> /usr/local/lib/libvtkWrappingPython36Core-8.2.so.1: error: undefined reference to ‘PyNumber\_Add’

There are a lots of “undefnied reference”. Not sure if you have ever seen them ?

---

<div class="post-metadata">

**Author:** ![phcerdan](https://discourse.itk.org/user_avatar/discourse.itk.org/phcerdan/32/286_2.png) [@phcerdan](https://discourse.itk.org/u/phcerdan)\
**Post date:** [October 17, 2019, 1:59pm UTC](https://discourse.itk.org/t/itk-python-wrapping-error-void-value-not-ignored-as-it-ought-to-be/948/11 "2019-10-17T13:59:02Z")

</div>

Not a surprise @Phong_Tran  
`PYTHON_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libpython3.6m.so`  
is a full path to the python library, but you are providing  
`PYTHON_LIBRARY:PATH=/usr/lib/python3.6`  
which is not a path to the library for sure.

Zooming out a little bit:  
The error I reported originally was solved `rebuilding` **VTK** with the same python I wanted to use in ITK, so I solved the problem first rebuilding `VTK`, and then ITK, _with the same python_.

I recommend you to do the same.

---

<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 18, 2019, 7:38am UTC](https://discourse.itk.org/t/itk-python-wrapping-error-void-value-not-ignored-as-it-ought-to-be/948/12 "2019-10-18T07:38:16Z")

</div>

Thanks @phcerdan, that works like a charm. I have another question that might not be related to the original question on the thread. But I still want to ask here that when I use the ITKVtkGluePython.py like the below snippet code

> import sys  
> import os  
> import itk  
> import vtk  
> itkToVtkFilter = ImageToVTKImageFilter[ImageType].New()

It throws exception:

> ╰─$ ~/workingspace/VTK-8.2.0/build/bin/vtkpython itk\_vtk\_server.py ~/tmp/dicom\_data/CT\_BVND2/1.3.46.670589.33.1.63686419356542268400001.5244014515565132624  
> Traceback (most recent call last):  
> File “itk\_vtk\_server.py”, line 58, in   
> ImageToVTKImageFilter = itk.ImageToVTKImageFilter[ImageType]  
> File “/home/phongtd/.local/lib/python3.6/site-packages/itkLazy.py”, line 52, in **getattribute**  
> itkBase.LoadModule(module, namespace)  
> File “/home/phongtd/.local/lib/python3.6/site-packages/itkBase.py”, line 128, in LoadModule  
> module = loader.load(swigModuleName)  
> File “/home/phongtd/.local/lib/python3.6/site-packages/itkBase.py”, line 253, in load  
> return importlib.import\_module(name)  
> File “/usr/lib/python3.6/importlib/ **init**.py”, line 126, in import\_module  
> return \_bootstrap.\_gcd\_import(name[level:], package, level)  
> File “”, line 994, in \_gcd\_import  
> File “”, line 971, in \_find\_and\_load  
> File “”, line 955, in \_find\_and\_load\_unlocked  
> File “”, line 665, in \_load\_unlocked  
> File “”, line 678, in exec\_module  
> File “”, line 219, in \_call\_with\_frames\_removed  
> File “/home/phongtd/.local/lib/python3.6/site-packages/itk/Configuration/…/ITKVtkGluePython.py”, line 15, in   
> ctypes.CDLL(\_vtkIOlib, ctypes.RTLD\_GLOBAL)  
> File “/usr/lib/python3.6/ctypes/ **init**.py”, line 348, in **init**  
> self.\_handle = \_dlopen(self.\_name, mode)  
> OSError: libvtkIO-8.2.so.1: cannot open shared object file: No such file or directory

I have no idea where to find the “libvtkIO-8.2.so.1”, since it does not exist in my VTK build as well in my installing dir: /usr/local/lib. Those errors might be related to the question I asked before on this thread [https://discourse.itk.org/t/itk-imagetovtkimagefilter-crashing-python/2018/4](https://discourse.itk.org/t/itk-imagetovtkimagefilter-crashing-python/2018/4)

@matt.mccormick, did you manage to isolate the issue ?

---

<div class="post-metadata">

**Author:** ![phcerdan](https://discourse.itk.org/user_avatar/discourse.itk.org/phcerdan/32/286_2.png) [@phcerdan](https://discourse.itk.org/u/phcerdan)\
**Post date:** [October 18, 2019, 8:13am UTC](https://discourse.itk.org/t/itk-python-wrapping-error-void-value-not-ignored-as-it-ought-to-be/948/13 "2019-10-18T08:13:12Z")

</div>

Glad that it worked!  
About the new question, I do not know, never faced it. But better ask in a new thread, or follow up in an existing conversation. It’s out of topic in this one.

---

<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:55am UTC](https://discourse.itk.org/t/itk-python-wrapping-error-void-value-not-ignored-as-it-ought-to-be/948/14 "2019-10-19T07:55:06Z")

</div>

Thank you @phcerdan, I already replied on the existing conversation ([itk.ImageToVTKImageFilter crashing Python](https://discourse.itk.org/t/itk-imagetovtkimagefilter-crashing-python/2018/5)). Hope that help others.
