0

I'm trying to figure out how can I execute Python code in a C++ program. Where, The C++ program will be a static Executable which will run on systems where python is NOT installed. But it can execute Python code without Python having to be installed on the System it's running on.

I looked onto embedding the python interpreter within my Program. I found this link Embedding Python in Another Application. But the file Python.h is not found anywhere on my system (Python 3.7). I really need help on this. What can I do to achieve this?

Lynx
  • 147
  • 2
  • 8
  • why is c++ involved at all? Is it an option to just give an executable where everything is in pure python? (essentially, is this an XY problem?) – Paritosh Singh Oct 01 '19 at 15:55
  • C++ is necessary due to project requirement. Also I do not trust python scripts that are converted to Executable. – Lynx Oct 01 '19 at 15:56
  • Have a look at [Cython](https://cython.org/). Not exactly C++, as you say is a requirement, but is similar to what you describe. – Pedro Rodrigues Oct 01 '19 at 15:59
  • You want to execute python code "where python is not installed". I don't think that's possible, you need a python interpreter somehow. – BiagioF Oct 01 '19 at 16:01
  • @BiagioFesta Well it is possible though. Just trying to figure out how. – Lynx Oct 01 '19 at 16:05
  • If you can get the python libraries and headers, just cannot run the executable, then you could "execute python" by interacting with the Python C API directly. – AndyG Oct 01 '19 at 16:09
  • Maybe this helps https://stackoverflow.com/a/57961942/10933809 – Oblivion Oct 01 '19 at 16:32

0 Answers0