473,503 Members | 7,578 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python in C integration and WxPython

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.
Sep 15 '05 #1
2 1919
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.


Sep 15 '05 #2
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.


Sep 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3825
by: Logan | last post by:
Several people asked me for the following HOWTO, so I decided to post it here (though it is still very 'alpha' and might contain many (?) mistakes; didn't test what I wrote, but wrote it - more or...
5
4190
by: Andr? Roberge | last post by:
Sorry about the cryptic subject line, but I wanted to capture the essence of my message in a single line. I am learning Python (which, as everyone know is the best language :-) so that I can...
47
3421
by: Kenneth McDonald | last post by:
Is there any emerging consensus on the "best" UI for toolkit. Tk never quite made it but from what I can see, both qt and wxWin are both doing fairly well in general. I'm already aware of the...
2
1697
by: rodmc | last post by:
I am totally new to Python and WxPython and need to write an application which can open up an external windows from a plug-in within GAIM (using pyGAIM). I have managed to hack some code together...
22
5024
by: Glurt Wuntal | last post by:
I am a newbie with Python. It's a great language, but I would like to be able to present a simple gui menu for some of my scripts; something better than using 'raw_input' prompts. Any...
8
2426
by: Aravind | last post by:
hi, some of my friends told that python and java are similar in the idea of platform independency. Can anyone give me an idea as i'm a newbie to java and python but used to C++. My idea is to...
5
3276
by: Laszlo Nagy | last post by:
Hello, I was trying to get answers for these. SPE homepage was down. Then I found it on berlios (http://developer.berlios.de/forum/forum.php?forum_id=12695) but no one answered since 5 days. In...
31
2445
by: sdoty044 | last post by:
Just wondering on what peoples opinions are of the GUIs avaiable for Python? All I am doing is prompting users for some data (listbox, radio buttons, text box, ect...). Then I will have some...
18
7396
by: Jens | last post by:
I'm starting a project in data mining, and I'm considering Python and Java as possible platforms. I'm conserned by performance. Most benchmarks report that Java is about 10-15 times faster than...
0
7070
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5566
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.