executing python within perl script

SS sridhara at yahoo.com
Thu Dec 18 22:18:45 CET 2003

I am trying to execute some python commands within a perl script and
running into problems. The following works:
python -c "import mypkg;do this; do that"
however when I try to do something like
#!/bin/perl -w
$cmd = "import mypkg; do this; do that";
$string = `python -c \"$cmd\"`;

and execute this perl script I get error:

Traceback (most recent call last):
  File "<string>", line 1, in ?
  File "/apps/relibase/python/reliscript/python/reliscript.py"
, line 228, in ?
    __internal__ = internal_storage()
  File "/apps/relibase/python/reliscript/python/reliscript.py"
, line 25, in __init__
    import re; self.re = re
  File "/apps/relibase/python/Python-2.1.1/Lib/re.py", line 28
, in ?
    from sre import *
  File "/apps/relibase/python/Python-2.1.1/Lib/sre.py", line 1
7, in ?
    import sre_compile
  File "/apps/relibase/python/Python-2.1.1/Lib/sre_compile.py"
, line 15, in ?
    assert _sre.MAGIC == MAGIC, "SRE module mismatch"
AssertionError: SRE module mismatch

More information about the Python-list mailing list