Message166447
| Author |
Grissiom.Gu |
| Recipients |
Grissiom.Gu |
| Date |
2012年07月26日.00:57:08 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1343264230.45.0.645552285699.issue15451@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年07月26日 00:57:10 | Grissiom.Gu | set | recipients:
+ Grissiom.Gu |
| 2012年07月26日 00:57:10 | Grissiom.Gu | set | messageid: <1343264230.45.0.645552285699.issue15451@psf.upfronthosting.co.za> |
| 2012年07月26日 00:57:09 | Grissiom.Gu | link | issue15451 messages |
| 2012年07月26日 00:57:08 | Grissiom.Gu | create |
|