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

G

Gregoire Banderet

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top