Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Python in C integration and WxPython

Reply
Thread Tools

Python in C integration and WxPython

 
 
Alain Paschoud
Guest
Posts: n/a
 
      09-15-2005
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.
 
Reply With Quote
 
 
 
 
David Wilson
Guest
Posts: n/a
 
      09-15-2005
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.


 
Reply With Quote
 
 
 
 
Alain Paschoud
Guest
Posts: n/a
 
      09-15-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.

>
>

 
Reply With Quote
 
 
 
Reply

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
[wxPython-users] ANNOUNCE: wxPython 2.6.3.0 Robin Dunn Python 0 03-28-2006 06:03 PM
[wxPython-users] Web based applications are possible with wxPython? Ruben Charles Python 6 10-25-2005 09:41 PM
wxPython - wx package (new style wxPython?) Logan Python 5 12-11-2003 04:12 PM
[PY GUI] interest function in python GUI(wxpython,pyqt) program.wxpython,pyqt ulysses Python 4 10-22-2003 03:28 PM
wxPython looses function "wxPython.wx.miscc" Anand Python 1 07-23-2003 01:59 AM



Advertisments