Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question

put on hold as off-topic by PolyGeo 23 hours ago

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions relating to general Information Technology, with no clear GIS component, are off-topic here, but can be researched/asked at Stack Overflow (software development), Super User (computing hardware and software) and Database Administrators (relational databases)" – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

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 Dec 22 '11 at 15:33
I think subprocess is the way to do this nowadays. – Paul Hiemstra Dec 22 '11 at 21:54
In addition, googling for "python run extrnal executable" got me the answer quite quickly. No offense, but have you tried this? – Paul Hiemstra Dec 22 '11 at 21:59
I wasn't aware subprocess before. – Ibe Dec 26 '11 at 3:46

2 Answers 2

up vote 8 down vote accepted

Use the subprocess module.


proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
print exit_code,,
share|improve this answer

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

share|improve this answer
Sorry for missing one important point that i have to run it in the arcgis environment. – Ibe Dec 22 '11 at 16:03
I'm not sure how that matters. If you're using a Python script, you should have access to any of the Python libraries. – Anthony -GISCOE- Dec 22 '11 at 16:31

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