简体   繁体   English

Python 没有为 aws sam cli 配置

[英]Python is not configured for aws sam cli

I am following this tutorial to build a SAM App: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-getting-started-hello-world.html我正在按照本教程构建 SAM 应用程序: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-getting-started-hello-world.html

When i did sam build , I got following error当我做sam build时,出现以下错误

❯ sam build
Building codeuri: hello_world/ runtime: python3.8 metadata: {} functions: ['HelloWorldFunction']

Build Failed
Error: 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?

I checked my python by doing this我通过这样做检查了我的 python

❯ which python
python: aliased to python3

And when i do python version, i got this当我做 python 版本时,我得到了这个

❯ python --version
Python 3.8.2

So what's i am missing and how to fix this problem?那么我缺少什么以及如何解决这个问题?

When selecting "Use the most popular runtime and package type? [y/N]" in the terminal, AWS SAM uses Python 3.9 runtime.在终端中选择"Use the most popular runtime and package type? [y/N]"时,AWS SAM 使用 Python 3.9 运行时。 This means you need to have Python 3.9 installed on your machine.这意味着您需要在计算机上安装 Python 3.9。

Also note, AWS SAM CLI does not support Python 3.10.另请注意,AWS SAM CLI 不支持 Python 3.10。 I had to downgrade to Python 3.9.11 in order for this to work.我必须降级到 Python 3.9.11 才能正常工作。

I was facing same issue but after setting python 3.8 in the classpath problem resolved.我遇到了同样的问题,但是在类路径中设置 python 3.8 后问题解决了。

python3 --version

solution found.找到解决方案。 you might have selected python3.8/python3.7 as your runtime for the app.您可能已选择 python3.8/python3.7 作为应用程序的运行时。 The error occurs when there is mismatching the python version of your system.当您的系统的 python 版本不匹配时,会发生该错误。 check python version: python3 --version and use the same runtime of app as same as your system's python version.检查 python 版本: python3 --version并使用与系统的 python 版本相同的应用程序运行时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM