472,354 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 software developers and data experts.

Embedded python: "import" problem

Vio
Hi,
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()
--------------

outputs:
['__builtins__', '__doc__', '__file__', '__name__', '_calendar',
'_controls', '_core', '_gdi', '_grid', '_html', '_misc', '_windows',
'_wizard']
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 ...

Related:
--------------

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()
--------------

outputs:
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.

Cheers,
Vio
Jul 18 '05 #1
0 2448

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

Similar topics

2
by: Torsten Mohr | last post by:
Hi, i tried to find the file and line in the C sources of python where the command "import" is implemented. Can anybody give me some hint on this? Thanks, Torsten.
2
by: Tian | last post by:
I am writing a python program which needs to support some plug-ins. I have an XML file storing some dynamic structures. XML file records some class names whose instance needs to be created in the...
3
by: gerald.maher | last post by:
Hi, I am trying to excuate the follwong code: I get the following error: Here is my Lib path:
0
by: Bill Davy | last post by:
I am working with MSVC6 on Windows XP. I have created an MSVC project called SHIP I have a file SHIP.i with "%module SHIP" as the first line (file is below). I run SHIP.i through SWIG 1.3.24...
3
by: Mudcat | last post by:
I have a directory structure that contains different modules that run depending on what the user selects. They are identical in name and structure, but what varies is the content of the functions....
3
by: gatoruss | last post by:
Newbie here with a (hopefully not) dumb question....tried searching around on the 'Net without success, so here goes.... I have been playing around with python. I wrote a script that sends an smtp...
6
by: bvdp | last post by:
I'm going quite nutty here with an import problem. I've got a fairly complicated program (about 12,000 lines in 34 modules). I just made some "improvements" and get the following error: bob$ mma...
1
by: =?ISO-8859-1?Q?Fr=E9d=E9ric_Degraeve?= | last post by:
Hello, I tried this code with vs7-8 and boost1.34.1-1.35.0 and my python is a 2.4. The call to Cpython works well but boost::python doesn't work. I've got an exception about an access violation...
1
by: sleek | last post by:
I am having trouble with the following code: PyObject *module = PyImport_ImportModule(modulename); if (module == NULL) { PyObject* et, *ev, *etr; PyErr_Fetch(&et, &ev, &etr); PyObject*...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

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.