1

I am working with the ArcGIS program that reads Python language. For that I've already implement scripts as script tool on the ArcGIS. Now I need to run in background an exe program "gams". Is it possible to do directly from the ArcGIS? Or is it possible to do with a new python script? And how can I do this?

1
  • You have error messages in a comment on an answer to your question but what we need is a code snippet that you are running and any errors that it produces in your question.
    – PolyGeo
    May 5, 2016 at 12:01

1 Answer 1

6

You can try to use a python script and use one of the two following modules. But think of it carefully as running a program out of a script can do many unpleasent things.

import subprocess
subprocess.call(['C:\\folder\\gams.exe'])

import os
os.system('"C:\\folder\\gams.exe"')

Update as it is about a file of the type .gms:

Check out the answers on this post: https://stackoverflow.com/questions/1811691/running-an-outside-program-executable-in-python

6
  • Thank's! I run a .gms file and I did: import subprocess subprocess.call(['F:\Otim\correct\ElectGV03.gms']) but arcgis gives me an error: Runtime error Traceback (most recent call last): File "<string>", line 70, in <module> File "C:\Python27\ArcGIS10.2\Lib\subprocess.py", line 493, in call return Popen(*popenargs, **kwargs).wait() File "C:\Python27\ArcGIS10.2\Lib\subprocess.py", line 679, in init errread, errwrite) File "C:\Python27\ArcGIS10.2\Lib\subprocess.py", line 896, in _execute_child startupinfo) WindowsError: [Error 193] %1 is not a valid Win32 application
    – S.Rai
    Apr 28, 2016 at 16:08
  • Ok thats different. I thought your programm is gams.exe and not xxx.gms . You have the problem that your windows does not recognize the filetype. Is the needed software installed? Can you double-click the file and it runs? Otherwise you have to assign the file type to the programm that should run it.
    – Matte
    Apr 28, 2016 at 16:23
  • Yes, Gams is installed at my computer. When I open the gams program and run the file .gms it runs, yes...
    – S.Rai
    Apr 28, 2016 at 16:27
  • See update on the answer. There are different possiblities and one should work for you....
    – Matte
    Apr 28, 2016 at 16:57
  • I put a link in the original answer where there are different options discussed to open a program via python.
    – Matte
    Apr 28, 2016 at 17:21

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