i have already searched through google, and many refence, but i only see a complex example of coding, would you give me an example (In Simple Code) so i can understand.
I’ve already code it, but it breaks everytime i run it
Here’s the code
#include <Python.h>
int main()
{
PyObject *pName, *pModule, *pDict, *pFun, *pValue;
// Initialize the Python Interpreter
Py_Initialize();
// Build the name object
pName = PyString_FromString("C:\\Documents and Settings\\MASTER\\My Documents\\Visual Studio 2010\\Projects\\Python\\Test.py");
if(pName)printf("OK");
// Load the module object
pModule = PyImport_Import(pName);
// pDict is a borrowed reference
pDict = PyModule_GetDict(pModule);
// pFunc is also a borrowed reference
pFun = PyDict_GetItemString(pDict, "prinTname");
if (PyCallable_Check(pFun))
{
PyObject_CallObject(pFun, NULL);
} else
{
PyErr_Print();
}
// Clean up
Py_DECREF(pModule);
Py_DECREF(pName);
Py_DECREF(pDict);
Py_DECREF(pFun);
// Finish the Python Interpreter
Py_Finalize();
getchar();
return 0;
}
and there are some messages
First-chance exception at 0x1e00503b in Python.exe: 0xC0000005: Access violation reading location 0x00000004.
Unhandled exception at 0x1e00503b in Python.exe: 0xC0000005: Access violation reading location 0x00000004.
The program ‘[4548] Python.exe: Native’ has exited with code 0 (0x0).
You most likely have not installed python dev tools, i.e. python.h is never found. Locate python.h and look for compile errors and repost if there are some.
Edit: This is old info. Including should be as easy as adding the include directory to the include directories, see: How do I get Visual Express 2010 to find my python.h header file?