'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
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?
Solution 1:[1]
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.
Solution 2:[2]
I was facing same issue but after setting python 3.8 in the classpath problem resolved.
Solution 3:[3]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | ashique |
Solution 2 | Dharman |
Solution 3 | PeeKay |