calling python (matplotlib) from c++

someone newsboost at gmail.com
Sun Dec 11 20:20:15 EST 2011


Hi all,

I want to call python (matplotlib) from C++. I use ubuntu linux and 
compile with "-lpython2.7". Besides that, I have this line included:

#include <python2.7/Python.h>

I can then do something like this:

   Py_Initialize();
   PyRun_SimpleString("print ' '");
   PyRun_SimpleString("print ' '");
   PyRun_SimpleString("print ' '");
   PyRun_SimpleString("print 'PYTHON RUNNING =============='");
   PyRun_SimpleString("from time import time,ctime\n"
                      "print 'Today is',ctime(time())\n");
   //  Py_Main(argc, argv); // start up the python interpreter
   Py_Finalize();

However - I cannot seem to pass two arrays of data, so I can plot the 
data using matplotlib... I cannot even start matplotlib... Please 
help/advice/come up with suggestions, someone who knows what to do :-)



More information about the Python-list mailing list