# is it possible to call a python script in a C++ program

**URL:** https://discourse.vtk.org/t/is-it-possible-to-call-a-python-script-in-a-c-program/2710
**Category:** Support
**Created:** [February 27, 2020, 9:12am UTC](https://discourse.vtk.org/t/is-it-possible-to-call-a-python-script-in-a-c-program/2710 "2020-02-27T09:12:53Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![embeddedmz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/embeddedmz/32/12_2.png) [@embeddedmz](https://discourse.vtk.org/u/embeddedmz)
#### Post date: [February 27, 2020, 9:12am UTC](https://discourse.vtk.org/t/is-it-possible-to-call-a-python-script-in-a-c-program/2710/1 "2020-02-27T09:12:53Z")

</div>

Hi,

In ParaView’s Catalyst, one can write a Python script and call it from a C++ context, I wonder if this feature can be achieved in pure VTK ?

Thanks.

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [February 27, 2020, 2:04pm UTC](https://discourse.vtk.org/t/is-it-possible-to-call-a-python-script-in-a-c-program/2710/2 "2020-02-27T14:04:57Z")

</div>

You can call Python code from C (regardless of VTK) using Python C API functions, such as `PyRun_String`.

---

<div class="post-metadata">

### Author: ![embeddedmz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/embeddedmz/32/12_2.png) [@embeddedmz](https://discourse.vtk.org/u/embeddedmz)
#### Post date: [February 27, 2020, 5:16pm UTC](https://discourse.vtk.org/t/is-it-possible-to-call-a-python-script-in-a-c-program/2710/3 "2020-02-27T17:16:10Z")

</div>

but is it possible to call my C++ VTK classes from the Python code ? or some wrapping is needed ?

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [February 27, 2020, 5:28pm UTC](https://discourse.vtk.org/t/is-it-possible-to-call-a-python-script-in-a-c-program/2710/4 "2020-02-27T17:28:59Z")

</div>

Yes, all Python-wrapped classes can be called from Python. The process for wrapping your VTK code has completely changed in VTK-8.9 and I cannot find a good documentation, but you can use [vtk-dicom](https://github.com/dgobbi/vtk-dicom/) as an example.

@ben.boeckel it would be great if first 5-10 pages that come up when googling “VTK Python wrapping” would contain current information or link to current information. It is extremely difficult to find relevant information about Python wrapping. I know that you added useful information to [VTK api documentation](https://vtk.org/doc/nightly/html/), but it seems that server-side search was not enabled when this documentation was generated, so there is way to find information about Python wrapping macros.

---

<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, 5:32pm UTC](https://discourse.vtk.org/t/is-it-possible-to-call-a-python-script-in-a-c-program/2710/5 "2020-03-16T17:32:32Z")

</div>

I’m not fluent in how to get Google to pay attention and rank the information appropriately. It used to be that linking to it would be enough, but now you need to convince the neural networks. [Here](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/6584) is an MR which enables client-side searching (I’m unsure of what we’d need to do to support the server-side searching).
