473,893 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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)w xGetFreeMemory( );"
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 "wxAssertFailur e" 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_wxP yApp>

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 2593

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

Similar topics

2
1766
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
3099
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 run time while parsing the XML file. I wonder what is the best solution for this problem? I also have some problem about the "import". How should I design my packages? Say, I have all code locates at c:\projects\sami, "c:\project" is in my...
3
3927
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
2737
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 to obtain SHIP_wrap.cpp and SHIP.py; the latter contains the line "import _SHIP". I compile SHIP_wrap.cpp and a bunch of files into a DLL which I have the
3
5438
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. They will only need to be run once per execution. Example (directory level): Sys1: A B C
3
2449
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 email. Here is the link that I found explaining how such a script could be written Sending an Email As you see it imports a module as follows: "import smtplib". I am using a linux machine (ubuntu ditro). It has both python2.5 and python2.4...
6
4595
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 Traceback (most recent call last): File "/usr/local/bin/mma", line 55, in <module> import MMA.main File "/usr/local/share/mma/MMA/main.py", line 33, in <module> import MMA.docs
1
1838
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 reading location 0x00000000. help, please? thank you.
1
1679
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* traceback = PyImport_ImportModule("traceback"); PyObject* tb = PyObject_CallMethodObjArgs(traceback, PyString_FromString("format_exception"), et, ev, etr, NULL);
0
9982
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9830
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11243
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10469
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9645
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8021
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5858
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6066
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4684
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 we have to send another system

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.