shell=True
is not needed with [sys.executable, 'demo_package/deploy_database.py']
, and causes problems. The way you're doing it (if you omit shell=True
) is the preferred way, because it bypasses the shell.
shell=True
makes Popen hand over the passed command to a shell (e.g. /bin/bash
, depending on the shell configured for the current user). Only the first command passed in the list is executed, the other elements of the list are passed as arguments to the shell itself (from the docs):
On Unix with shell=True […] If args is a sequence, the first item specifies the command string, and any additional items will be treated as additional arguments to the shell itself.
shell=True
is a bit dangerous, but also useful in some cases. See the documentation for details.