I'm trying to embed python into c to use it for configuration:
If I do it like this:
/******************************************************************************
*
* Embeding Python Example
*
* To run:
* gcc -c test.c -o test.o -I"C:/Python25/include"
* gcc -o test.exe test.o -L"C:/Python25/libs" -lpython25
* test.exe
*
******************************************************************************/
#include <Python.h>
int main(int argc, char *argv[])
{
PyObject *run;
PyObject *globals = PyDict_New();
PyObject *locals = PyDict_New();
Py_Initialize();
run = PyRun_String("from time import time,ctime\n"
"print 'Today is',ctime(time())\n"
"test = 5\n"
"print test\n", Py_file_input, globals, locals);
Py_Finalize();
return 0;
}
I'm getting a runtime error from the the Microsoft VIsual C++ Runtime, with this message:
Exception exceptions.ImportError: '__import__ not found' in 'garbage collection' ignored
Fatal Python error: unexpected exception during garbage collection
What am I doing wrong?