简体   繁体   English

在Python 2.7上在后台执行游戏

[英]Execute Gams in background on Python 2.7

I need to call and run gams at background from a Python script. 我需要从Python脚本在后台调用和运行gams。

I'm using: 我正在使用:

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

And it gives me this error: 它给了我这个错误:

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. 追溯(最近一次通话):文件“ F:/Otim/Interface/tent_backgroundgams.py”,行91,位于subprocess.check_call([r“ C:\\ GAMS \\ win64 \\ 24.4 \\ gams.exe”,r“ F :\\ Otim \\ Interface \\ ElGrs。gms“])文件” C:\\ Python27 \\ ArcGIS10.2 \\ lib \\ subprocess.py“,第511行,在check_call中引发CalledProcessError(retcode,cmd)CalledProcessError:命令'['C: \\ GAMS \\ win64 \\ 24.4 \\ gams.exe','F:\\ Otim \\ Interface \\ ElGr。 gms']' returned non-zero exit status 6 gms']'返回了非零退出状态6

How can I solve it? 我该如何解决?

Here is a list of the meanings of the different exit codes: https://www.gams.com/help/index.jsp?topic=%2Fgams.doc%2Fuserguides%2Fuserguide%2F_u_g__g_a_m_s_return_codes.html 以下是不同退出代码的含义的列表: https : //www.gams.com/help/index.jsp?topic=%2Fgams.doc%2Fuserguides%2Fuserguide%2F_u_g__g_a_m_s_return_codes.html

So, 6 means "there was a parameter error" (because the file specified could not be found with the extra whitespace). 因此,6表示“存在参数错误”(因为找不到带有多余空格的指定文件)。 3 means "there was an execution error". 3表示“存在执行错误”。 So, there was some error while GAMS runs you model. 因此,GAMS运行模型时出现了一些错误。 By default you should find an lst file (ElGrs.lst) in your working copy. 默认情况下,您应该在工作副本中找到一个lst文件(ElGrs.lst)。 If you search for "****" in that file, you should see what went wrong and where the error appears. 如果在该文件中搜索“ ****”,则应该查看出了什么问题以及错误出现的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM