Launching Python from Python

Jay O'Connor oconnor at bioreason.com
Fri Jul 27 12:45:18 EDT 2001


All,

I'm trying to launch another program from a Python program.  The other
program happens to be another Python program.  I thought spawnle would
be the proper place.  However, it doesn't seem to be working.

	import os
	pid = os.spawnle (os.P_NOWAIT,
			"c:\\python20\\python.exe",
			["c:\\james\\development\\python\\test.py"],
			{"PYTHONPATH":"c:\\james\\python"})

my understanding is that this should spawn the other process, running
the python runtime and passing in my script name.

However, it doesn't quite happen.  What happens is that it launches
python in interactive mode.  If I import sys, sys.path has my added path
above, buy sys.argv is an array with one empty string.

Any ideas why it doesn't work?  Any other ideas on how to launch another
python program from within one?

This is on WinNT, BTW

Take care,
Jay O'Connor
oconnor at bioreason.com



More information about the Python-list mailing list