help! Troubled when embed python into C++

孟炜 willgun at live.cn
Sun May 24 06:42:13 EDT 2009


I have the following codes in C++: 
#include <Python.h> 
void main(){ 
Py_Initialize(); 
PyRun_SimpleString("execfile(r'1.py')"); 
Py_Finalize(); 
return; 
} 

the following is in 1.py  : 
import Tkinter 
root=Tkinter.Tk() 
root2=Tkinter.Tk() 
root.mainloop() 
root2.mainloop() 

this is the output after I run the c++ program: 
Traceback (most recent call last): 
  File " <string>", line 1, in <module> 
  File "g:\volatile\1.py", line 2, in <module> 
    root=Tkinter.Tk() 
  File "C:\Python26\lib\lib-tk\Tkinter.py", line 1638, i 
    baseName = os.path.basename(sys.argv[0]) 
AttributeError: 'module' object has no attribute 'argv' 

I am quite new to python ,anyone know what shoud i do to solve it?
Thanks a lot!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090524/4557cfb9/attachment.html>


More information about the Python-list mailing list