Using AWS SAM default template in PyCharm: Python Version Error

If you are using Pycharm default template to create your AWS serverless application, you may have run into the following issue.

docker ps

/usr/local/bin/sam build HelloWorldFunction –template /Users/appc/PycharmProjects/workspacesskill/template.yaml –build-dir /Users/appc/PycharmProjects/workspacesskill/.aws-sam/build

Building codeuri: /Users/appc/PycharmProjects/workspacesskill/hello_world runtime: python3.6 metadata: {} architecture: x86_64 functions: [‘HelloWorldFunction’]

Build Failed

Error: PythonPipBuilder:Validation – Binary validation failed for python, searched for python in following locations  : [‘/usr/bin/python’, ‘/usr/local/opt/python/libexec/bin/python’] which did not satisfy constraints for runtime: python3.6. Do you have python for runtime: python3.6 on your PATH?

While you fix this a number of ways fixing changing the path or fixing the version installed on your system, my recommendation is much simpler. To change the template.yaml This exactly to what this file is for.

In this case, the Build requires python3.6 version. My system is installed with 3.9.9. So all I need to do is change the template.yaml file to 3.9

That’s all folks!
 
-arun.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s