I have spent a good part of my day trying to run a Python file from c++. I have tried:
. . .
FILE * file = fopen ("file.py", "r");
PyRun_SimpleFile (file, "file.py");
. . .
This however just causes my application to crash. I am using python version 3.4.
1 Answer 1
Try
Py_Initialize();
PyRun_SimpleFile (file, "file.py");
Py_Finalize();
answered Nov 4, 2014 at 21:32
marsh
2,7505 gold badges33 silver badges57 bronze badges
Sign up to request clarification or add additional context in comments.
4 Comments
Ricky Mutschlechner
Also possibly dumb, but make sure that you're doing
#include <Python.h> marsh
Perhaps post the code that prints, or the contents of the python file.
default