How can I run multiple python scripts? At the moment I run one like so python script1.py
.
I've tried python script1.py script2.py
and that doesn't work: only the first script is run. Also, I've tried using a single file like this;
import script1
import script2
python script1.py
python script2.py
However this doesn't work either.
I had to do this and used subprocess.
You can use Gnu-Parallel to run commands concurrently, works on Windows, Linux/Unix.
parallel ::: "python script1.py" "python script2.py"
You try the following ways to run the multiple python scripts:
Note: The execution of multiple scripts depends purely underlined operating system, and it won't be concurrent, I was new comer in Python when I answered it.
Update: I found a package: https://pypi.org/project/schedule/ Above package can be used to run multiple scripts and function, please check this and maybe on weekend will provide some example too.
i.e: import schedule import time import script1, script2
If you want to run two Python scripts in parallel then just include the following at the end of your script:
I do this in node.js (on Windows 10) by opening 2 separate cmd instances and running each program in each instance.
This has the advantage that writing to the console is easily visible for each script.
I see that in python can do the same: 2 shells.
The most simple way in my opinion would be to use the PyCharm IDE and install the 'multirun' plugin. I tried alot of the solutions here but this one worked for me in the end!