En Tue, 27 Oct 2009 03:25:54 -0300, Brandon Keown <keown.bran...@gmail.com> escribió:

I am going to try to embed python in an application, but in simple
testing, I could not get it to work.  The following code seems like it
should work, but it crashes, and I have tried several things.  What
could I be doing wrong?

#include <Python.h>

int main(int argc, char* argv[])
{
        FILE* fp = fopen("test.py","r");
        Py_Initialize();
        PyRun_SimpleFile(fp,"test.py");
        Py_Finalize();
        return 0;
}

Crashes, how? Try running inside a debugger to see where it crashes, or at least put a few printf. You didn't test for the fopen result; are you sure "test.py" exists in the current directory at the time you run it?

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to