<div>thanks robert for the reply,and i have understood your revision on my script and i also feel sorry for not making you understand my intention,and here i will say it once more.</div> <div>it is a python script project which uses python/c api to make the python interpreter for the script.and the python script part is something a simple frame , and in the c/c++ part, the work will involve with extending the python script functionality.</div> <div>which starts like:</div> <div>Py_Initialize();</div> <div>PyImport_ImportModule("app");</div> <div><EM>and later goes on with the other operation</EM></div> <div>and the nightmare comes when i import the app python script.and it throws the notorious import error<EM>:ImportError:no module named "_core_",</EM>which actually resides in the location of C:\Python24\Lib\site-packages\wx-2.6-msw-unicode\wx,with other files named _core.py, _core.pyc. it seems that the python doesnot find the search path.and i added to
the sys.path, to check whether the path now can be found,i type "import _core_".it response by"no module named _core_",.furthermore after checking this failure, i add the _core_.pyd,_core.py,_core.py directory to the path(advance->environment variable).certainly the sys.path increase the specific directory.but still when wanting to check whether it is feasible,the error remains(no module named "_core_").</div> <div>hope that u can get what i explains to u, pls be patient with a non-english country guy.thanks again :)</div> <div>regards,</div> <div>jolley</div> <div><BR><BR><B><I>Robert Ramsdell <rcriii@ramsdells.net></I></B> 写道:</div> <BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">Hello Jolley. I'm not sure what is going on with your code, but try<BR>this for the Python side of things:<BR><BR>import wx<BR><BR>class MyApp(wx.Frame):<BR>def __init__(self, title='MyApp'):<BR>self.app =
wx.PySimpleApp()<BR>self.title = title<BR>self.windowCaption = title<BR>wx.Frame.__init__(self,None,wx.ID_ANY, self.windowCaption,<BR>size=(200,100),<BR>style=wx.DEFAULT_FRAME_STYLE|<BR>wx.NO_FULL_REPAINT_ON_RESIZE)<BR><BR>app = MyApp()<BR>app.mainloop()<BR><BR>I posted a more elaborate example to the list last week.<BR><BR>Robert<BR><BR>On Mon, 2006-11-13 at 16:38 +0800, 放茗 谈 wrote:<BR>> hello,all guys,<BR>> i am starting to make a python gui app with wxPython, and later<BR>> i want to using c extension to call it.<BR>> there is my python code(app.py):<BR>> <BR>> from wxPython.wx import *<BR>> class MyApp(wxApp):<BR>> def OnInit(self):<BR>> frame = wxFrame(NULL,-1,"Hello from wxPython")<BR>> frame.Show(true)<BR>> self.SetTopWindow(frame)<BR>> return true<BR>> app = MyApp(0)<BR>> app.MainLoop()<BR>> <BR>> and also the c extension code<BR>> <BR>> #include "python.h"<BR>> //#include "wxPython.h"<BR>> #include
<IOSTREAM><BR>> using namespace std;<BR>> static PyMethodDef g_methodDefinition = {NULL};<BR>> #define ERROR(pyObject,msg) {if (pyObject == NULL){printf("%<BR>> s",msg);PyErr_Print();exit(1);}}<BR>> int main()<BR>> {<BR>> PyObject<BR>> *pWorkObject,*pModule,*pClass,*pInstance,*pMethod;//,*pWxpythonModule;<BR>> Py_Initialize();<BR>> if (!Py_IsInitialized())<BR>> {<BR>> cerr << "can not initialize the python object!" << endl;<BR>> return -1;<BR>> }<BR>> //pWxpythonModule = PyImport_ImportModule("wxPython.wx");<BR>> //ERROR(pWxpythonModule,"cannot load wxPython.wx");<BR>> <BR>> //load the module<BR>> pModule = PyImport_ImportModule((char*)"app");<BR>> ERROR(pModule,"can not load app module!")<BR>> .//omit some<BR>> when the code comes to import the app module,it crashed.later with<BR>> PyErr_Print,i get the error message is as follow:<BR>> can not load app module!Traceback (most recent call
last):<BR>> File "c:\Program Files\Microsoft Visual Studio\MyProjects<BR>> \runPythonGUI\app.py"<BR>> , line 1, in ?<BR>> from wxPython.wx import *<BR>> File "C:\Python24\lib\site-packages\wx-2.6-msw-unicode\wxPython<BR>> \__init__.py",<BR>> line 10, in ?<BR>> import _wx<BR>> File "C:\Python24\lib\site-packages\wx-2.6-msw-unicode\wxPython<BR>> \_wx.py", line<BR>> 3, in ?<BR>> from _core import *<BR>> File "C:\Python24\lib\site-packages\wx-2.6-msw-unicode\wxPython<BR>> \_core.py", lin<BR>> e 15, in ?<BR>> import wx._core<BR>> File "C:\Python24\lib\site-packages\wx-2.6-msw-unicode\wx<BR>> \__init__.py", line 4<BR>> 2, in ?<BR>> from wx._core import *<BR>> File "C:\Python24\lib\site-packages\wx-2.6-msw-unicode\wx\_core.py",<BR>> line 4, i<BR>> n ?<BR>> import _core_<BR>> ImportError: No module named _core_<BR>> Press any key to continue<BR>> though i have added the directory where the pyd lives
in sys.path or<BR>> the environment,it doesnot come into effect.also, as the _core_.pyd<BR>> is accompanied with _core.py and _core.pyc.and it means that it can<BR>> satisfy the basic need that pyd searches the path.and i can make sure<BR>> that the problem can not come because it is a .pyd.<BR>> any suggestions and feedback will be greatly appreciated!<BR>> thanks ,really<BR>> regards,<BR>> jolley<BR>> <BR>> <BR>> ______________________________________________________________________<BR>> 雅虎免费邮箱-3.5G容量,20M附件<BR>> _______________________________________________<BR>> Chicago mailing list<BR>> Chicago@python.org<BR>> http://mail.python.org/mailman/listinfo/chicago<BR><BR>_______________________________________________<BR>Chicago mailing list<BR>Chicago@python.org<BR>http://mail.python.org/mailman/listinfo/chicago<BR></BLOCKQUOTE><BR><p> 
                <hr size=1><a href="http://cn.mail.yahoo.com/" target=blank>
雅虎免费邮箱-3.5G容量,20M附件</a>