I would like to run an external executable written in fortran which provides one of the inputs inside a python code.

Is it possible to run that exe inside Python script?

  • 3
    I suggest migrating this question to SO if it doesn't get a quick answer here, because it really is seeking pure Python expertise. (You can migrate it by following the "flag" link to contact a moderator.)
    – whuber
    Commented Dec 22, 2011 at 15:33
  • 1
    I think subprocess is the way to do this nowadays. Commented Dec 22, 2011 at 21:54
  • 3
    In addition, googling for "python run extrnal executable" got me the answer quite quickly. No offense, but have you tried this? Commented Dec 22, 2011 at 21:59
  • I wasn't aware subprocess before.
    – Ibe
    Commented Dec 26, 2011 at 3:46

2 Answers 2


Use the subprocess module.


proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
print exit_code,stdout.read(),stderr.read()

Look into os.system and related Python stuff. SO is a good place to ask related questions.

  • Sorry for missing one important point that i have to run it in the arcgis environment.
    – Ibe
    Commented Dec 22, 2011 at 16:03
  • 3
    I'm not sure how that matters. If you're using a Python script, you should have access to any of the Python libraries. Commented Dec 22, 2011 at 16:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.