470,601 Members | 1,253 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,601 developers. It's quick & easy.

Embedded python: "import" problem

I've been trying to embed (statically) wxPy alongside an embedded py
interpreter on a linux/gtk box.

At one point, for some reason misc.o linking reported "multiple
definitions of wxGetFreeMemory()". Since wxGetFreeMemory() seemed
effectively unused in gtk, I just commented it out in misc_wrap.cpp
(didn't want to patch SWIG to regenerate the wrapper code, so hacked the
generated cpp source), and replaced "result=(long)wxGetFreeMemory();"
with "result=0;". Crossed some fingers...

All compiled and links without errors. (but don't try this at home
folks: an almost 20MB executable)
Anyhow, executing from the embedded interpreter the following:

import _core
import _misc
import _windows
import _controls
import _calendar
import _gdi
import _grid
import _html
import _wizard
print dir()

['__builtins__', '__doc__', '__file__', '__name__', '_calendar',
'_controls', '_core', '_gdi', '_grid', '_html', '_misc', '_windows',
but then continuing with:


import core
import misc
import windows
import controls
import calendar
import gdi
import grid
import html
import wizard


Modules - misc, calendar, grid, html, wizard - they all report
ImportError: No module named ...


import core


import core
File "somepath/core.py", line 9444, in ?
from misc import *
ImportError: No module named misc
Which is rather odd. Some unsuccessful hacks:
'core.py': around line 9444 replaced "from misc import *" to "from _misc
import *". Only to get stopped by the next line (and last line) in
"cope.py" with:

../src/helpers.cpp(680): assert "wxAssertFailure" failed: Unable to find
stock object [in child thread]

Commenting out last line of core.py and running:

print "core.Frame>", core.Frame
print "core.App>", core.App
a = core.App()

core.Frame> <class 'windows.Frame'>
core.App> <class 'core.App'>
Segmentation fault

but if I do:
a = _core.new_PyApp()
print a
<core.PyApp; proxy of C++ wxPyApp instance at _e8c2e408_p_wxPyApp>

So I don't quite see the big picture here. The good news is that
embedded py has access to wx classes, albeit in this not very pythonish
raw form, bad news is that I don't quite understand why embedded py
interpreter can import some embedded modules (like core and gdi), but
fails to import some others (like misc or html). I'm not too sure what
causes the segfault, but I suspect some dependencies on the failed
imports perhaps? I included my little hack in misc_wrap.cpp, just in
case it plays a role here which I missed.

Any suggestions welcome, but basically I would appreciate if someone can
point me what possibly could make some of these wx modules to get
imported, and some to give me an Import Error.

Jul 18 '05 #1
0 2382

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Torsten Mohr | last post: by
6 posts views Thread by bvdp | last post: by
1 post views Thread by =?ISO-8859-1?Q?Fr=E9d=E9ric_Degraeve?= | last post: by
1 post views Thread by sleek | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.