无法访问AWS Lambda实例上的Python Pulp解算器

时间:2017-11-29 21:19:36

标签: python aws-lambda pulp

1 个答案:

答案 0 :(得分:1)

我终于解决了,它是求解器(cbc)上的权限问题。它可能与压缩过程有关,我还没有到底,但是我能够通过将解算器文件(cbc)复制到/ var / tmp(以允许访问)来解决问题,然后将权限更改为可执行文件。我用来做这个的python代码如下所示:

# Copy solver to tmp
copyfile('pulp/solverdir/cbc/linux/64/cbc', '/tmp/cbc')
# Change permissions to executable
mode = os.stat('/tmp/cbc').st_mode
mode |= (mode & 0o444) >> 2    # copy R bits to X
os.chmod('/tmp/cbc', mode)   
# Solve using the newly located cbc solver
prob.solve(COIN_CMD(path="/tmp/cbc"))