在Python 2.7的后台执行Gams

时间:2016-09-05 10:38:08

标签: python python-2.7 subprocess gams-math

我需要在Python脚本的后台调用和运行gams。

我正在使用:

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

它给了我这个错误:

  

Traceback(最近一次调用最后一次):文件   " F:/Otim/Interface/tent_backgroundgams.py" ;,第91行,在       subprocess.check_call([R" C:\ GAMS \ Win64的\ 24.4 \ gams.exe" R" F:\奥蒂姆\界面\ ElGrs。   gms"])文件" C:\ Python27 \ ArcGIS10.2 \ lib \ subprocess.py",第511行,in   check_call       raise CalledProcessError(retcode,cmd)CalledProcessError:Command' [' C:\ GAMS \ win64 \ 24.4 \ gams.exe',' F:\ Otim \ Interface \ ElGr。   克']'返回非零退出状态6

我该如何解决?

1 个答案:

答案 0 :(得分:0)

以下列出了不同退出代码的含义:https://www.gams.com/help/index.jsp?topic=%2Fgams.doc%2Fuserguides%2Fuserguide%2F_u_g__g_a_m_s_return_codes.html

因此,6表示“存在参数错误”(因为无法找到指定的文件和额外的空格)。 3表示“存在执行错误”。因此,GAMS运行模型时会出现一些错误。默认情况下,您应该在工作副本中找到lst文件(ElGrs.lst)。如果您在该文件中搜索“****”,您应该会看到出错的地方以及错误出现的位置。