How to run external program?

Viewer T. dtgeadamo at yahoo.com
Fri Jan 12 06:00:07 EST 2007


Lad wrote:
> How  can I run external program from Python?
> I use Python with XP
> Thank you for help

A possible way to do this is the following:
Let's say we want to run a program called program.exe from the path
C/Program/Program.exe. We would first need to import the os module and
type the following:

import os                                        #import the os module
path = 'C:/Program/Program.exe'      #give the pathname of the external
program as a string
os.system(path)                              #execute the program from
python using the os module

There are many other ways, but this should work for short pathnames
without spaces.




More information about the Python-list mailing list