修改SAM模板中的Python运行时版本,以使其与本地电脑环境一致。例如,如果本地电脑安装了Python 3.7,则将SAM模板中的Python运行时版本改为3.7。
示例代码(在SAM模板中指定Python3.7运行时版本):
{
"AWSTemplateFormatVersion": "2010-09-09",
"Transform": "AWS::Serverless-2016-10-31",
"Resources": {
"FunctionName": {
"Type": "AWS::Serverless::Function",
"Properties": {
"Runtime": "python3.7",
"Handler": "app.lambda_handler",
"CodeUri": "./"
}
}
}
}