[New-bugs-announce] [issue20927] Different behaviour on Posix and Windows when using subprocess.Popen(..., cwd=path)

Jovik report at bugs.python.org
Fri Mar 14 17:59:45 CET 2014


New submission from Jovik:

This works on Linux as expected:
import subprocess
proc = subprocess.Popen(["./app"], stdout=subprocess.PIPE, cwd="workspace")

but on Windows I get:
FileNotFoundError: [WinError 2] The system cannot find the file specified

To successfully execute it on Windows I need to set shell=True first:
proc = subprocess.Popen(["app.exe"], stdout=subprocess.PIPE, cwd="workspace", shell=True)

which is odd since by default it should use cwd when searching for binary:
"If cwd is not None, the function changes the working directory to cwd before executing the child. In particular, the function looks for executable (or for the first item in args) relative to cwd if the executable path is a relative path."
from http://docs.python.org/3.3/library/subprocess.html

----------
assignee: docs at python
components: Documentation
messages: 213570
nosy: Jovik, docs at python
priority: normal
severity: normal
status: open
title: Different behaviour on Posix and Windows when using subprocess.Popen(..., cwd=path)
type: behavior
versions: Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20927>
_______________________________________


More information about the New-bugs-announce mailing list