This is a simple command that works from command line:
> python -c "print('asdasd')"
asdasd
But it fails to output anything when executed from the script:
import os
import sys
import subprocess
cmd = [sys.executable] + ['-c', '"print(\'asdasd\')"']
print cmd
kwargs = {
'stdout': subprocess.PIPE,
'stderr': subprocess.PIPE,
'stdin': subprocess.PIPE,
}
print subprocess.Popen(cmd).communicate()
print subprocess.Popen(cmd, **kwargs).communicate()
The output:
['C:\\Python27\\python.exe', '-c', '"print(\'asdasd\')"']
(None, None)
('', '')
Why it doesn't produce anything? I am out of ideas. Looks like a bug in Python 2.7.11 to me.