Thursday, 8 August 2013

Call a python script in a python script

Call a python script in a python script

I am trying to call a python script in another python script. The
directories are different. I tried
import subprocess
subprocess.call("C:\temp\hello2.py", shell=True)
But got nothing. It does not work. I reviewed many forums, but all of them
are about calling it when both scripts are on the same directory.
I tried having both scripts in the same directory. In this case, I can run
the model in the Python.exe (through cmd window) but not in IDLE. In IDLE,
I do not even get an error message.
I really need to do that, such that I can't define the other script as a
different module, etc. I need to call a script in another script.

No comments:

Post a Comment