Author Grissiom.Gu
Recipients Grissiom.Gu
Date 2012-07-26.00:57:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
My system is 32 bit win7 and python is 2.7.2.

Sample code is here:
import os, sys

nenv = {}
nenv['PATH'] = 'C:\\Windows\\System32\\;e:\\projects\\teest\\python\\exe\\'
nenv['SystemRoot'] = 'C:\\Windows\\'

#os.putenv('PATH', nenv['PATH'])
import subprocess
proc = subprocess.Popen('test.bat', stdin=subprocess.PIPE, stdout=subprocess.PIPE,
    stderr=subprocess.PIPE, shell = False, env=nenv)
data, err = proc.communicate()
rv = proc.wait()

if data:
    print data
if err:
    print err
in E:\projects\teest\python I have two folders: 'exe/' have a bat file named 'test.bat' and a 'launch/' folder have the above script. When execute the above script, python yield "WindowsError: [Error 2]" which means could not find the executable.

However, if I un-comment the line "#os.putenv('PATH', nenv['PATH'])", it works like a charm. It seems _subprocess.CreateProcess does not honer the PATH.

FYI, if I use the CreateProcess of win32 extensions, thing works fine without the need to export PATH.
Date User Action Args
2012-07-26 00:57:10Grissiom.Gusetrecipients: + Grissiom.Gu
2012-07-26 00:57:10Grissiom.Gusetmessageid: <>
2012-07-26 00:57:09Grissiom.Gulinkissue15451 messages
2012-07-26 00:57:08Grissiom.Gucreate