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?

Em Ae
  • 8,167
  • 27
  • 95
  • 162
  • Some ideas [here](https://github.com/aws/aws-toolkit-jetbrains/issues/1749) to check the runtime in your template.yaml and consider re-installing awscli and sam – jarmod Dec 19 '20 at 03:03
  • already verified the python version. right now uninstalling all pythons/aws-cli and sam cli – Em Ae Dec 19 '20 at 03:11
  • 1
    This solved the problem: https://stackoverflow.com/questions/65180787/how-to-export-path-to-sam-build-command – Em Ae Dec 19 '20 at 03:47
  • @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?"](https://stackoverflow.com/help/self-answer). – Jens Dec 19 '20 at 11:13

3 Answers3

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.

ashique
  • 935
  • 2
  • 8
  • 26
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.

PeeKay
  • 59
  • 1
  • 4
0

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

Dharman
  • 30,962
  • 25
  • 85
  • 135
jagdish khetre
  • 1,381
  • 2
  • 8
  • 15