473,320 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 2530

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*...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.