New submission from Pekka Klärck: If you add a directory into PATH on Windows so that the directory is in quotes, subprocess does not find executables in it. They are found by the operating system, though, at least when run on the command prompt.
To reproduce: C:\>python --version Python 2.7.3 C:\>type test\script.bat @echo off echo hello C:\>set ORIG=%PATH% C:\>set PATH=%ORIG%;test C:\>script.bat hello C:\>python -c "from subprocess import call; call('script.bat')" hello C:\>set PATH=%ORIG%;"test" C:\>script.bat hello C:\>python -c "from subprocess import call; call('script.bat')" Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Python27\lib\subprocess.py", line 493, in call return Popen(*popenargs, **kwargs).wait() File "C:\Python27\lib\subprocess.py", line 679, in __init__ errread, errwrite) File "C:\Python27\lib\subprocess.py", line 896, in _execute_child startupinfo) WindowsError: [Error 2] The system cannot find the file specified I don't think you ever need those quotes, even if the directory would have spaces, but it is very confusing that the behavior is different on the command prompt and with subprocess. Additionally, Linux does not suffer from this problem: $ python --version Python 2.7.3 $ cat test/script.sh #!/bin/sh echo "hello" $ PATH=$PATH:test script.sh hello $ PATH=$PATH:test python -c "from subprocess import call; call('script.sh')" hello $ PATH=$PATH:"test" script.sh hello $ PATH=$PATH:"test" python -c "from subprocess import call; call('script.sh')" hello ---------- messages: 180520 nosy: pekka.klarck priority: normal severity: normal status: open title: Subprocess does not find executable on Windows if it is PATH with quotes _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17023> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com