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

Discussion in 'Python' started by stefan, Dec 8, 2004.

  1. stefan

    stefan Guest

    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
    stefan, Dec 8, 2004
    #1
    1. Advertising

  2. Re: after embedding and extending python (using swig) problem importing(non-core) modules

    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
    >
    vincent wehren, Dec 8, 2004
    #2
    1. Advertising

  3. stefan

    Donnie Leen Guest

    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
    Donnie Leen, Dec 8, 2004
    #3
  4. stefan

    stefan Guest

    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
    stefan, Dec 8, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Axel Diener
    Replies:
    0
    Views:
    350
    Axel Diener
    Feb 11, 2004
  2. dmoore
    Replies:
    5
    Views:
    652
    dmoore
    Jul 19, 2007
  3. Basha J P M
    Replies:
    0
    Views:
    241
    Basha J P M
    Oct 11, 2008
  4. moerchendiser2k3

    Python Embedding Importing relative modules

    moerchendiser2k3, Jul 6, 2010, in forum: Python
    Replies:
    7
    Views:
    484
  5. Gyoung-Yoon Noh
    Replies:
    1
    Views:
    96
    James Britt
    Dec 24, 2005
Loading...

Share This Page