Embedded python (use of modules) on system w/o Python installed

Discussion in 'Python' started by Gregoire Banderet, Jan 15, 2004.

  1. Hi there,

    I try to run a python script from a C program.
    The script uses the re (regex) module.
    The resulting executable must run on a system that has no lib and
    python script module, i.e no re.py

    How should I write my C program (I'd like to avoid any python file
    installation on target system) ?
    Now it is:
    --------- C prg ----------
    #include <python2.2/Python.h>
    #define PYTHON_SCRIPT "test.py"

    int main(int argc, char * argv[])
    {
    FILE *fd = fopen(PYTHON_SCRIPT, "r");
    Py_Initialize();
    PyRun_SimpleFile(fd, PYTHON_SCRIPT);
    Py_Finalize();
    return 0;
    }
    ----------------------------


    ---------- test.py ----------
    import re

    p = re.compile('(ab)*')
    print p.match('ababababab').span()
    ------------------------------


    But when I run pytest on the target system:
    # ./pytest
    'import site' failed; use -v for traceback
    Traceback (most recent call last):
    File "test.py", line 1, in ?
    import re
    ImportError: No module named re
    Gregoire Banderet, Jan 15, 2004
    #1
    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. Miki Tebeka
    Replies:
    2
    Views:
    657
    Miki Tebeka
    Jul 7, 2004
  2. Replies:
    3
    Views:
    440
    Jason
    Apr 28, 2008
  3. KillSwitch
    Replies:
    3
    Views:
    374
    Gabriel Genellina
    Oct 28, 2009
  4. PerlFAQ Server
    Replies:
    0
    Views:
    87
    PerlFAQ Server
    Jan 30, 2011
  5. PerlFAQ Server
    Replies:
    0
    Views:
    93
    PerlFAQ Server
    Mar 5, 2011
Loading...

Share This Page