Answer the question
In order to leave comments, you need to log in
How to execute python from c++?
How to correctly call a python script from pluses, execute a python script and get a result from it. Let there be a conditional program on the pluses that counts a + b, a we received and implemented on the pluses, b is already implemented in python, we find it perfectly there, it turns out that it needs to be transferred to the application on pys, the result of Python calculations, you need to calculate on pys a + b. Do something in c++, something in python, and continue working with this data in c++.
Answer the question
In order to leave comments, you need to log in
Well, first you need to decide whether it is possible to leave two programs separately, connecting them via standard input / output, files or sockets? Let one start another simply as a child process, this is the easiest.
If it categorically should be one program, then you need to decide who will be the "main".
If Python is the main one, which should call the C / C ++ code (designed as a DLL), then the ctypes model may come in handy. Alternatively, one can write an interpreter module .
If C++ is the main one, which should execute python code, then you already need to read about python embedding .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question