New submission from Grissiom Gu <chaos.pro...@gmail.com>:

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
sys.exit(rv)
==========================
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.

----------
messages: 166447
nosy: Grissiom.Gu
priority: normal
severity: normal
status: open
title: PATH is not honored in subprocess.Popen in win32
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue15451>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to