Skip to content
Advertisement

Run console command with python

This code works fine directly in CLI:

JavaScript

Now, I need to execute the same command but in Python environment. This is what I am trying:

JavaScript

This is the error, and I am running the file and command from the same location:

JavaScript

Advertisement

Answer

you can just use os.system() if you have nothing else to do with spawned process.

but, if you really want to use subprocess.call and stream redirection, you must use it like following:

JavaScript

please, notice that subprocess.call takes program name and its params as a string list, maybe it’s the problem

Advertisement