0

I am trying to run multiple python scripts in parallel with subprocess in a linux OS

Similar to this: Running multiple commands from multiple terminal windows from python script

Here is what I tried:

subprocess.call(['gnome-terminal', '-e', "python3 ab.py"])
subprocess.call(['gnome-terminal', '-e', "python3 bc.py"])
subprocess.call(['gnome-terminal', '-e', "python3 cd.py"])

Unfortunately, the terminal flashes in split seconds and disappears. Any reason for this? adding shell=True makes the terminal stays but does not execute the script.

1

2 Answers 2

3

subprocess.run should work:

subprocess.Popen(['gnome-terminal', '-e', "python3", "ab.py"], shell=True)
subprocess.Popen(['gnome-terminal', '-e', "python3", "bc.py"], shell=True)
subprocess.Popen(['gnome-terminal', '-e', "python3", "cd.py"], shell=True)

Edit:

os.system("gnome-terminal -x python ab.py")
Sign up to request clarification or add additional context in comments.

14 Comments

It does this same. what could be the issue?
it doesnt. it shows the shell and then the script did not run. I dont know whats wrong
I tried with the shell=True. The terminal stays but does not run the python script. Any thoughts around this?
@JA-pythonista I edited with 4 elements in a list, did you see that edit?
Yes, I did. It opens the terminal and does nothing
|
0

Do you need to split all parts of the command line into separate strings?

subprocess.call(['gnome-terminal', '-e', "python3", "ab.py"])

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.