[Tutor] about calling external program in Python

Alan Gauld alan.gauld at freenet.co.uk
Wed May 17 23:05:06 CEST 2006


I think you may be confiused about sys.path.

------------------------
import os
import sys
sys.path.append('C:\Program Files\EPANET2')
os.system('epanet2d.exe C:\simulation_test\Network3_1.inp
C:\simulation_test\Network3_1.out')
----------------------

sys.path is the path that Python uses to look for python modules.
It has nothing to do with the PATH environment variable used by
the OS to find executables.

> In the Pythonwin interface to run. I got nothing.
> Then I added 'C:\Program Files\EPANET2' into the system path.

Do you mean the OS system PATH?

> In the cmd line: I typed python c:\test.py. It ran and then gave the 
> output.
> Don' t know why command line works. but pythonwin interface failed .

If you are doing what I think rthen Pythonwin doesn't see the PATH but
The cmd line will use the PATH environment variable to find the 
executable.

Alan G. 




More information about the Tutor mailing list