473,748 Members | 9,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

after embedding and extending python (using swig) problem importing (non-core) modules

Hi Folks,

I currenty extended some of my C++ functionality to python and also
embedded python to use python functionality in my C++ system (and use
as well these extended functions).

While this works fine with the core python functionality, as soon as I
run a script (on the embedded system) which tries to import modules
which are not in the core system, like "xml" or "re", it fails and says
it cannot find the related dll (for example in the case of re the
_sre.pyd). It works fine if i run the script with the 'regular'
interpreter.

It does not look like a path-problem to me, so I'm clueless right now.
I could work around this extending some functions to python and use
them, but then I lose what I was aiming for, the "power" of python and
python-modules.

Do i have to tell the embedded python system somehow where to look for
extension dll's? (it even does not work if i have the pyd files in the
(same) folder than the system where I start my embedded python program.

It would be great if someone would have an idea, at least how to get me
started on this.

thanks a lot in advance,
-stefan

Jul 18 '05 #1
3 2004
stefan wrote:
Hi Folks,

I currenty extended some of my C++ functionality to python and also
embedded python to use python functionality in my C++ system (and use
as well these extended functions).

While this works fine with the core python functionality, as soon as I
run a script (on the embedded system) which tries to import modules
which are not in the core system, like "xml" or "re", it fails and says
it cannot find the related dll (for example in the case of re the
_sre.pyd). It works fine if i run the script with the 'regular'
interpreter.
Is this in debug mode? If so, make sure you have the debug versions of
those dll's in your path (i.e. _sre_d.pyd etc.)...

HTH
--
Vincent Wehren

It does not look like a path-problem to me, so I'm clueless right now.
I could work around this extending some functions to python and use
them, but then I lose what I was aiming for, the "power" of python and
python-modules.

Do i have to tell the embedded python system somehow where to look for
extension dll's? (it even does not work if i have the pyd files in the
(same) folder than the system where I start my embedded python program.

It would be great if someone would have an idea, at least how to get me
started on this.

thanks a lot in advance,
-stefan

Jul 18 '05 #2
Du you use program in linux? I work in windows, but I think it's a way
to tell your program the module path like this:

char path[MAX_PATH], cpy_cmd[MAX_PATH];
GetCurrentDirec tory( MAX_PATH, path );
sprintf( cpy_cmd, "sys.path.appen d(r\'%s\\module s\')", path );
PyRun_SimpleStr ing("import sys"); // load build-in
module sys
PyRun_SimpleStr ing( cpy_cmd ); // set my modules path

Jul 18 '05 #3
thanks a lot for the quick answer.

I had to provide the debug-versions, since I was in debug mode, like
you already expected! thanks a lot again!

-stefan

Jul 18 '05 #4

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

Similar topics

3
3618
by: Harish | last post by:
I am using Python2.3 version with SWIG-1.3.19 to access C++ interface provided by a DLL. Some of its function returns MFC class objects like CString , CMap. I tried to generate wrapper for these classes using SWIG by including respective header files in .i file. But it doesn't work. Swig reports hundreds parsing errors in MFC's file. Could you give me any directions.. Thank you in anticipation
0
2505
by: Helmut Zeisel | last post by:
I want to build a static extension of Python using SWIG and VC++ 6.0 as described in http://www.swig.org/Doc1.3/Python.html#n8 for gcc. My file is testerl.i: ========================= %module testerl extern int hz(int i);
0
1737
by: Hugh Macdonald | last post by:
I've got a slight problem... and I'm stuck as to where to go with it... I'm running on Redhat7.2, using Python 2.2.2 I've got a compiled module that I wrote almost a year ago - it works fine, and I've never had any problems with it... I also did an extension to a plugin (Shake) using Python, so the plugin loads a python module and calls various functions in there.... all in all, fine - I thought I had my head around the system, and...
0
2144
by: Shankar | last post by:
Hello, I have a C++ dll with one class which has one public function. This function returns an std::list<std::wstring> as an argout. I am using SWIG to generate Python extensions for this dll. I have the following code in python to access the string from the list. .. ..
6
3008
by: Qun Cao | last post by:
Hi Everyone, I am a beginner on cross language development. My problem at hand is to build a python interface for a C++ application built on top of a 3D game engine. The purpose of this python interface is providing a convenient scripting toolkit for the application. One example is that a user can write a python script like: player = Player() game.loadPlayer(player) player.moveTo(location)
0
1181
Bulldog
by: Bulldog | last post by:
I have been playing around with this issue for a while and seen some previous posting trying to address the problem but I haven't seen any answers to the problem so I am reposting it in my quest for a solution. I am using python 2.2.3, because I am using some dSpace software (controldesk/automationdesk) that is based upon that version of python. I have some pre-compiled python modules that come with the dspace applications. I am pretty sure...
3
2685
by: dmoore | last post by:
Hi Folks: I have a question about the use of static members in Python/C extensions. Take the simple example from the "Extending and Embedding the Python Interpreter" docs: A simple module method: static PyObject * spam_system(PyObject *self, PyObject *args)
1
2555
by: nimitsis | last post by:
Hello I am trying to convert and manage a simple structure C ,to Python by using SWIG. The code is the following : /* example.c*/ double sum(Vector c) { return c.x+c.y+c.z; } /*header.h*/ struct Vector{ double x,y,z;
0
2114
by: Tim Spens | last post by:
--- On Fri, 6/27/08, Tim Spens <t_spens@yahoo.comwrote: I think I know where the problem is but I'm unsure how to fix it. When I call Register_Handler(...) from python via callback.setHandler1(callback1) this only seems to affect pythons ability to trigger an "event" in c. PyObject *Handler is always NULL even after I call Register_Handler(...). I thought there was some magic here that was assigning the pointer *Handler to my python...
0
9374
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9325
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9249
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
8244
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
6796
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
6076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4607
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...
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.