Can't use subprocess.Popen() after os.chroot() - why?

Erik erik.williamson at
Sun Sep 4 16:22:07 CEST 2011

Hi All,

I'm trying to do the following: 

import os
from subprocess import Popen, PIPE

p = Popen("/bin/date", stdin=PIPE, stdout=PIPE, stderr=PIPE)
stdout_val, stderr_val = p.communicate()
print stdout_val

but the Popen call is dying with the following exception:

Traceback (most recent call last):
  File "./", line 7, in <module>
    p = Popen("/bin/date", stdin=PIPE, stdout=PIPE, stderr=PIPE)
  File "/home/erik/lib/python2.7/", line 679, in __init__
  File "/home/erik/lib/python2.7/", line 1224, in _execute_child
  File "/home/erik/lib/python2.7/", line 1382, in loads
  File "/home/erik/lib/python2.7/", line 858, in load
  File "/home/erik/lib/python2.7/", line 971, in load_string
LookupError: unknown encoding: string-escape

Am I missing something here? does the chroot environment need to be populated with more than just the date executable in this case? I can't seem to find any examples of this & would appreciate any insight.  


More information about the Python-list mailing list