473,324 Members | 2,246 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,324 software developers and data experts.

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 1975
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];
GetCurrentDirectory( MAX_PATH, path );
sprintf( cpy_cmd, "sys.path.append(r\'%s\\modules\')", path );
PyRun_SimpleString("import sys"); // load build-in
module sys
PyRun_SimpleString( 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
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...
0
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...
0
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,...
0
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. ...
6
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...
0
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...
3
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...
1
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; } ...
0
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...
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
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.