I am very new to Python. I am trying to run some shell commands via Python’s subprocess.run()
. I would also like to capture the output of the shell commands. When I run the command with capture_output=False
, it seems to run fine. But when I switch it to True
, I get an error.
import subprocess
# runs just fine
subprocess.run("git --version", capture_output=False)
# throws error
subprocess.run("git --version", capture_output=True)
## OSError: [WinError 6] The handle is invalid