Problem embedding Python.

Brandon Keown keown.brandon at gmail.com
Tue Oct 27 06:04:55 EDT 2009


I found the problem.  Evidently as posted on a few other areas of the
internet, this is a common problem when trying to use compilers that
may have different type definitions for (FILE*).  Here is workable
solution:

#include <Python.h>

int main(int argc, char* argv[])
{
	PyObject* PyFileObject;
	char* filename;
	Py_Initialize();
	filename = "c:\\Patches\\Test\\Debug\\test.py";
	PyFileObject = PyFile_FromString(filename, "r");
	PyRun_SimpleFile(PyFile_AsFile(PyFileObject), filename);
	Py_Finalize();
	return 0;
}



More information about the Python-list mailing list