Em *_* Ae 5 python amazon-web-services aws-lambda serverless aws-sam
我正在按照本教程构建 SAM 应用程序:https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-getting-started-hello-world.html
\n当我这样做时sam build,我收到以下错误
\xe2\x9d\xaf sam build\nBuilding codeuri: hello_world/ runtime: python3.8 metadata: {} functions: [\'HelloWorldFunction\']\n\nBuild Failed\nError: PythonPipBuilder:Validation - Binary validation failed for python, searched for python in following locations : [\'/usr/bin/python\'] which did not satisfy constraints for runtime: python3.8. Do you have python for runtime: python3.8 on your PATH?\nRun Code Online (Sandbox Code Playgroud)\n我通过这样做检查了我的Python
\n\xe2\x9d\xaf which python\npython: aliased to python3\nRun Code Online (Sandbox Code Playgroud)\n当我做 python 版本时,我得到了这个
\n\xe2\x9d\xaf python --version\nPython 3.8.2\nRun Code Online (Sandbox Code Playgroud)\n那么缺少什么以及如何解决这个问题呢?
\npython3 --version
Run Code Online (Sandbox Code Playgroud)
找到解决方案。您可能选择了 python3.8/python3.7 作为应用程序的运行时。当您的系统的 python 版本不匹配时,就会出现该错误。检查 python 版本: python3 --version并使用与系统的 python 版本相同的应用程序运行时。
小智 5
"Use the most popular runtime and package type? [y/N]"在终端中选择时,AWS SAM 使用 Python 3.9 运行时。这意味着您需要在计算机上安装 Python 3.9。
另请注意,AWS SAM CLI 不支持 Python 3.10。我必须降级到 Python 3.9.11 才能使其正常工作。