Python subprocess with stdout as a string Aug 3, 2016 python You can use subprocess.check_output which will redirect stdout to the function call’s return value Something like: import subprocess output = subprocess.check_output(['which', 'python']) print(output)