If I write program in python 2.7 and I want to run another script file with another python (2.6) how can I do this?
EDIT: I do this, because I need Django (which is installed in python 2.7) and I need some programs that are only available for python 2.6…
EDIT2: So I wrote simple script, that will be executed in python 2.6 and I will get results from it right in python 2.7
You have several options, but the most general concept is to use
os.systemto do your script execution.Explicit interpreter
Relying on shebang for choosing the right interpreter
For this to work your script has to have the first line set to
And your
python2.6executable needs to be in yourPATH.If you need stdin/stdout manipulation
See http://docs.python.org/library/subprocess.html#subprocess.Popen