Recommended library for executing shell commands in Python
I recommend using invoke
instead of the built-in subprocess
to handle executing any shell command in Python.
Not only does invoke‘s run()
it provide a more user friendly syntax compared to e.g. subprocess.check_output()
:
run('make')
but it also tends to act more like you’d expect especially regarding the output of the command and has easy-to-use parameters such as hide=True
to hide the output of shell commands.
Furthermore, it provides a buch of really useful features such as automatically responding to prompts from the shell command.