2

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

4

Try

Py_Initialize();
    PyRun_SimpleFile (file, "file.py");
Py_Finalize();
Sign up to request clarification or add additional context in comments.

4 Comments

Also possibly dumb, but make sure that you're doing #include <Python.h>
Now if I run the code it says File "file.py", line 1 ufffd/ufffd/ufffd/etc.
Well it is loading the python file but I'm getting that weird error
Perhaps post the code that prints, or the contents of the python file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.