Getting Python version

Another question for you @dgobbi. How can I detect VTKs Python version?

I tried this:

 execute_process(COMMAND "${_vtk}/bin/vtkpython" -c "import sys; sys.stdout.write('.'.join(map(str, sys.version_info[:2])))" OUTPUT_VARIABLE py_ver)

But not all VTK installations have that executable.

I already asked that on the old mailing list.

The VTK cmake configuration does not export that information, so there is no guaranteed way to detect it. This kind of stuff frustrates me all the time, too. The Kitware folks seem to want to limit the number of exported CMake variables to an absolute minimum.

1 Like