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:
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();
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
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();
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 ?
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 rebuildingVTK 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.
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
╰─$ ~/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
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.