Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > after embedding and extending python (using swig) problem importing (non-core) modules

Reply
Thread Tools

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

 
 
stefan
Guest
Posts: n/a
 
      12-08-2004
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

 
Reply With Quote
 
 
 
 
vincent wehren
Guest
Posts: n/a
 
      12-08-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
>

 
Reply With Quote
 
 
 
 
Donnie Leen
Guest
Posts: n/a
 
      12-08-2004
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

 
Reply With Quote
 
stefan
Guest
Posts: n/a
 
      12-08-2004
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python Embedding Importing relative modules moerchendiser2k3 Python 7 07-06-2010 09:56 PM
Importing v reloading modules modules Peter Peyman Puk Python 0 03-19-2010 05:09 PM
problem with embedding python 2.3 and importing win32 extensions Axel Diener Python 0 02-11-2004 07:14 AM
Importing modules from within other modules Tobiah Python 2 09-14-2003 09:18 PM



Advertisments