Python in C integration and WxPython

Alain Paschoud alain.paschoud at fastcom.ch
Thu Sep 15 17:25:44 CEST 2005


Hi David,

Thanks for your answer, but I don't think the problem comes from which
Python version I use. I installed the Python from cygwin, but this
didn't change everything.

Finally, I fullfill the PYTHONPATH environment variable to make the
system finding the wx module. It is now able to find it. But after that,
the mode _core is called, and finally, the module _core_, which is not
found. The only _core_ file that I have is the "_core_.pyd" which is in
the wx directory. Of course, I added this directory path to PYTHONPATH,
but without any success.... is it because this is a .pyd file ?

Here are the logs I get:

Traceback (most recent call last):
  File "Dialog.py", line 2, in ?
    import  wx
  File "C:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx\__init__.py",
line 42, in ?
    from wx._core import *
  File
"/cygdrive/c/Python24/Lib/site-packages/wx-2.6-msw-ansi/wx/_core.py",
line 4, in ?
    import _core_

Here is the result of the Py_GetPath() function:

/cygdrive/c/Python24/Lib/site-packages/:/cygdrive/c/Python24/Lib/site-packages
/wx-2.6-msw-ansi/:/cygdrive/c/Python24/Lib/site-packages/wx-2.6-msw-ansi/wxPython:/cygdriv
e/c/Python24/Lib/site-packages/wx-2.6-msw-ansi/wx:.:/usr/bin/lib/python24.zip:/usr/bin/lib
/python2.4/:/usr/bin/lib/python2.4/plat-cygwin:/usr/bin/lib/python2.4/lib-tk:/usr/bin/lib/
python2.4/lib-dynload

Any hints ??

Thanks.

N.B: Same problem when I run the script directly with "python -v Dialog.py".

David Wilson wrote:
> It sounds like your C program and Python script are running under
> different interpreters. Your C program almost certainly is using a
> Python version that comes with Cygwin, while the script is probably
> using a native win32 Python that has wxPython installed.
> 
> Assuming this is true, then compiling your C program natively on
> Windows should solve the problem. Alternatively, if wxPython is
> available for cygwin (possibly via cygwin's X server) then installing
> it would also help.
> 
> 
> David.
> 
> 
> Alain Paschoud wrote:
> 
>>Hi all,
>>
>>I made a small dialog in WxPython. I can run the python script with a
>>double-click or through command line, and everything goes fine (dialog
>>appears, which means that wx module has been found).
>>Then, I decided to write a C program (under Windows, with Cygwin) that
>>will read my script (through PyRun_SimpleFile() function) and run it.
>>But the system doesn't find the wx module to import...
>>
>>Traceback (most recent call last):
>>  File "Dialog.py", line 2, in ?
>>    import  wx
>>ImportError: No module named wx
>>
>>How can I say to my program where to search for this module ? I tried to
>>set $PYTHONPATH and $PYTHONHOME, but this doesn't change anything.
>>
>>More generally : Does a C program that embedded python run an external
>>executable (interpreter), or does it only load libraries ?
>>
>>Thank you very much for any help on this topic.
>>
>>Best regards.
> 
> 



More information about the Python-list mailing list