Python is not configured for aws sam cli
Asked Answered
J

3

5

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

When i did sam build, I got following error

❯ 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

❯ which python
python: aliased to python3

And when i do python version, i got this

❯ python --version
Python 3.8.2

So what's i am missing and how to fix this problem?

Jobbery answered 19/12, 2020 at 2:56 Comment(4)
Some ideas here to check the runtime in your template.yaml and consider re-installing awscli and samTsosie
already verified the python version. right now uninstalling all pythons/aws-cli and sam cliJobbery
This solved the problem: #65181287Jobbery
@EmAe If that solved your problem, please write an answer to your own question and accept it. This is allowed. See help center "Can I answer my own question?".Walloping
P
5
python3 --version

solution found. you might have selected python3.8/python3.7 as your runtime for the app. The error occurs when there is mismatching the python version of your system. check python version: python3 --version and use the same runtime of app as same as your system's python version.

Peloquin answered 20/12, 2021 at 11:0 Comment(0)
N
5

When selecting "Use the most popular runtime and package type? [y/N]"in the terminal, AWS SAM uses Python 3.9 runtime. This means you need to have Python 3.9 installed on your machine.

Also note, AWS SAM CLI does not support Python 3.10. I had to downgrade to Python 3.9.11 in order for this to work.

Nace answered 5/5, 2022 at 10:5 Comment(1)
But downgrading the system Python on a linux distro these days is suicidal.Ausgleich
V
0

I was facing same issue but after setting python 3.8 in the classpath problem resolved.

Venal answered 18/12, 2021 at 12:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.