Execute Gams in background on Python 2.7
<p>I need to call and run gams at background from a Python script.</p>

<p>I'm using: </p>

<pre><code>import subprocess
subprocess.check_call([r"C:\GAMS\win64\24.4\gams.exe",r"F:\Otim\Interface\ElGr.gms"])
</code></pre>

<p>And it gives me this error: </p>

<blockquote>
  <p>Traceback (most recent call last):   File
  "F:/Otim/Interface/tent_backgroundgams.py", line 91, in 
      subprocess.check_call([r"C:\GAMS\win64\24.4\gams.exe",r"F:\Otim\Interface\ElGrs.
  gms"])   File "C:\Python27\ArcGIS10.2\lib\subprocess.py", line 511, in
  check_call
      raise CalledProcessError(retcode, cmd) CalledProcessError: Command '['C:\GAMS\win64\24.4\gams.exe', 'F:\Otim\Interface\ElGr.
  gms']' returned non-zero exit status 6</p>
</blockquote>

<p>How can I solve it?</p>

<p>Here is a list of the meanings of the different exit codes: <a href="https://www.gams.com/help/index.jsp?topic=%2Fgams.doc%2Fuserguides%2Fuserguide%2F_u_g__g_a_m_s_return_codes.html" rel="nofollow">https://www.gams.com/help/index.jsp?topic=%2Fgams.doc%2Fuserguides%2Fuserguide%2F_u_g__g_a_m_s_return_codes.html</a></p>

<p>So, 6 means "there was a parameter error" (because the file specified could not be found with the extra whitespace). 3 means "there was an execution error". So, there was some error while GAMS runs you model. By default you should find an lst file (ElGrs.lst) in your working copy. If you search for "****" in that file, you should see what went wrong and where the error appears.</p>

python python-2.7 subprocess gams-math