472,353 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 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 1898
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...
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...
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...
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...
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...
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...
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...
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...
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...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
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...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
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...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
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...
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....
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

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.