title: Problems calling Python from C++
body: <p>test.py</p>
  
  <pre><code>def add(a,b):
   """  """
   print a,b,a+b
   return a+b
  </code></pre>
  
  <p>c program</p>
  
  <pre><code>#include &lt;python.h&gt;
  int _tmain(int argc, _TCHAR* argv[])
  {
   try
   {
    PyObject *pName,*pModule,*pDict,*pFunc,*pArgs1,*pArgs2,*pOutput;
  
    Py_Initialize();
    if(!Py_IsInitialized())
     return -1;
    pModule=PyImport_ImportModule("test");
  
    pDict=PyModule_GetDict(pModule);
  
    pFunc=PyDict_GetItemString(pDict,"add");
    pArgs1=Py_BuildValue("ii", 1,2); 
    //pArgs2=Py_BuildValue("i", 2); 
  
    pOutput=PyEval_CallObject(pFunc,pArgs1);
  
    int c=0;
    PyArg_Parse(pOutput, "d", &amp;c);
    cout&lt;&lt;c;
  
    //PyRun_SimpleString("");
  
    Py_Finalize();
   }
   catch(exception* ex)
   {
    cout&lt;&lt;ex-&gt;what();
   }
   char c;
   cin&gt;&gt;c;
   return 0;
  }
  </code></pre>
  
  <p>Console print nothing and closed.</p>
  
  <p>What's wrong?</p>
  
  <p>Thanks!</p>