Python embedded interpreter: how to initialize the interpreter ?

Ziga Seilnacht ziga.seilnacht at gmail.com
Wed Jan 3 02:00:26 CET 2007


ycollet at freesurf.fr wrote:
> Hello,
>
> I've written a C embedded application. I want to open a python gui
> application in my C program but when I do :
>
> PyRun_String( "import gui.py", file_input, pDictionary, pDictionary );
>
> the interpreter emits an error: tkinter module not defined
>
> What script must I load to initialize the embedded python interpreter
> so as I have the same modules in the python command line and in the
> python embedded interpreter ? /usr/lib/python2.4/*.py ??
>
> Yann COLLETTE

Did you call the Py_Initialize() function before trying to execute that
statement? Note also that you might have to Py_SetProgramName(somepath)
before calling Py_Initialize(). See the documentation for details:
http://docs.python.org/ext/embedding.html
http://docs.python.org/api/embedding.html

Hope this helps,
Ziga




More information about the Python-list mailing list