# Call Python Script from C++

**URL:** https://discourse.paraview.org/t/call-python-script-from-c/12486
**Category:** Development
**Created:** [July 10, 2023, 8:48pm UTC](https://discourse.paraview.org/t/call-python-script-from-c/12486 "2023-07-10T20:48:14Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Muhammad\_Saad\_Atique](https://discourse.paraview.org/user_avatar/discourse.paraview.org/muhammad_saad_atique/32/11159_2.png) [@Muhammad\_Saad\_Atique](https://discourse.paraview.org/u/Muhammad_Saad_Atique)
#### Post date: [July 10, 2023, 8:48pm UTC](https://discourse.paraview.org/t/call-python-script-from-c/12486/1 "2023-07-10T20:48:14Z")

</div>

I am creating Paraview’s custom application in C++. How can I execute python script from my C++ code.  
In my python script I am selecting points based on ID

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [July 13, 2023, 2:13pm UTC](https://discourse.paraview.org/t/call-python-script-from-c/12486/2 "2023-07-13T14:13:35Z")

</div>

See uses of `vtkPythonInterpreter` class in ParaView/VTK code. For example, `vtkPythonAnimationCue` is a C++ animation component that executes Python code to do processing in Python at each animation step.

ref: [https://gitlab.kitware.com/paraview/paraview/-/blob/master/Remoting/Animation/vtkPythonAnimationCue.cxx](https://gitlab.kitware.com/paraview/paraview/-/blob/master/Remoting/Animation/vtkPythonAnimationCue.cxx)

---

<div class="post-metadata">

### Author: ![Muhammad\_Saad\_Atique](https://discourse.paraview.org/user_avatar/discourse.paraview.org/muhammad_saad_atique/32/11159_2.png) [@Muhammad\_Saad\_Atique](https://discourse.paraview.org/u/Muhammad_Saad_Atique)
#### Post date: [July 13, 2023, 4:39pm UTC](https://discourse.paraview.org/t/call-python-script-from-c/12486/3 "2023-07-13T16:39:10Z")

</div>

Thank you, I tried following the example but seems like there is an issue with my project setup or the way I am calling python

```auto
C:\Users\msaad\AppData\Local\Programs\Python\Python311\include\object.h(239,23): error C2059: syntax error: ';' [C:\Users\msaad\M3SIMGui\build\client\m3sim_gui.vcx
proj]
C:\Users\msaad\AppData\Local\Programs\Python\Python311\include\object.h(239,23): error C2238: unexpected token(s) preceding ';' [C:\Users\msaad\M3SIMGui\build\clie
nt\m3sim_gui.vcxproj]

```

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [July 19, 2023, 1:47pm UTC](https://discourse.paraview.org/t/call-python-script-from-c/12486/4 "2023-07-19T13:47:11Z")

</div>

Not entire sure what could be the issue without looking at the code. One thing that comes to mind is make sure `vtkPython.h` is the first file included in the `.cxx` file, eg. [https://gitlab.kitware.com/paraview/paraview/-/blob/master/Remoting/Animation/vtkPythonAnimationCue.cxx#L16](https://gitlab.kitware.com/paraview/paraview/-/blob/master/Remoting/Animation/vtkPythonAnimationCue.cxx#L16)
