import subprocess
import os
def execute():
code = "def Solution():\n\tprint('Hello')\n\nSolution()\n"
f = open('/tmp/Solution.py','w')
f.write(code+'\n')
f.close()
s = subprocess.check_output("python /tmp/Solution.py", shell = True)
return s
我正在从云函数处理程序调用execute函数。这在本地有效,但在gcloud子进程上有效。check_输出返回非零退出代码
是因为gcloud运行时环境找不到python解释器吗?在这两种情况下,我怎么能做这样的事情?我错过了什么?我的日志中没有太多信息,所以我被卡住了
谢谢
您必须期望将函数部署到包含Python运行时的容器中。您不能假设云函数也包含shell。因此,不建议在python代码中使用
subprocess
相关问题 更多 >
编程相关推荐