# Getting Python version

**URL:** <https://discourse.vtk.org/t/getting-python-version/1563>\
**Category:** Development\
**Created:** [August 12, 2019, 7:55pm UTC](https://discourse.vtk.org/t/getting-python-version/1563 "2019-08-12T19:55:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ron84](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ron84/32/630_2.png) [@Ron84](https://discourse.vtk.org/u/Ron84)\
**Post date:** [August 12, 2019, 7:55pm UTC](https://discourse.vtk.org/t/getting-python-version/1563/1 "2019-08-12T19:55:45Z")

</div>

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

I tried this:

```auto
 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.

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [August 12, 2019, 8:43pm UTC](https://discourse.vtk.org/t/getting-python-version/1563/2 "2019-08-12T20:43:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)\
**Post date:** [March 16, 2020, 2:21pm UTC](https://discourse.vtk.org/t/getting-python-version/1563/3 "2020-03-16T14:21:17Z")

</div>

It is guaranteed that `find_package(PythonN)` will be called if you request a Python-using component when finding VTK. There is (now?) a [mention in the docs](https://gitlab.kitware.com/vtk/vtk/-/blob/fb069aa25572f3e9a693894e653431bfd10660e1/CMake/vtk-config.cmake.in#L36) on how to request Python information at the top of `vtk-config.cmake`.
