我正在尝试从AWS构建和运行示例python应用程序。我刚刚安装了python,下面是命令行提供的..。
D:\Udemy Work>python
Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
D:\Udemy Work>pip -V
pip 21.1.3 from c:\users\user\appdata\local\programs\python\python39\lib\site-packages\pip (python 3.9)当我运行sam build时,会得到以下错误
Build Failed
Error: PythonPipBuilder:Validation - Binary validation failed for python, searched for python in following locations : ['C:\\Users\\User\\AppData\\Local\\Programs\\Python\\Python39\\python.EXE', 'C:\\Users\\User\\AppData\\Local\\Microsoft\\WindowsApps\\python.EXE'] which did not satisfy constraints for runtime: python3.8. Do you have python for runtime: python3.8 on your PATH?下面是我的代码
template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
python-test
Sample SAM Template for python-test
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 3
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: hello_world/
Handler: app.lambda_handler
Runtime: python3.8
Events:
HelloWorld:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /hello
Method: getapp.py
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
python-test
Sample SAM Template for python-test
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 3
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: hello_world/
Handler: app.lambda_handler
Runtime: python3.9
Events:
HelloWorld:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /hello
Method: get如果在yaml中更改运行时,则会得到以下错误
PS D:\Udemy Work\awslambda\python-test> sam build
Building codeuri: D:\Udemy Work\awslambda\python-test\hello_world runtime: python3.9 metadata: {} functions: ['HelloWorldFunction']
Build Failed
Error: 'python3.9' runtime is not supported这里的解决方案是什么?
https://stackoverflow.com/questions/68438620
复制相似问题