Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: help! Troubled when embed python into C++

Thread Tools

Re: help! Troubled when embed python into C++

A. Cavallo
Posts: n/a
You need the:

int main(int argc, char * argv[])
PySys_SetArgv(argc, argv);
return 0;


On Sunday 24 May 2009 11:42:13 *炜 wrote:
> I have the following codes in C++:
> #include <Python.h>
> void main(){
> Py_Initialize();
> PyRun_SimpleString("execfile(r'')");
> Py_Finalize();
> return;
> }
> the following is in :
> 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\", line 2, in <module>
> root=Tkinter.Tk()
> File "C:\Python26\lib\lib-tk\", 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!

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
apwvnd Dr. Michael E. Kan: deeply troubled and incompetent, a very ill man. dhebv Fritz Wuehler Digital Photography 0 07-14-2011 05:40 PM
Raymond Karczewski: A Brother and a Troubled Man Computer Support 2 09-01-2007 12:32 PM
Troubled authentication in subdirectories Benton ASP .Net 1 03-24-2007 01:00 AM
hi groupers, i got troubled with linux and tomcat 5.x Java 3 09-23-2006 12:53 PM