How to export PATH to “sam build” command?

ⅰ亾dé卋堺 提交于 2021-01-05 08:51:14

问题


I'm developing AWS Lambda function on PyCharm. When I do "Run" button, Following error message.

/usr/local/bin/sam build MyFunction --template /Users/miyashiiii/Works/myapp/myapp/template.yaml --build-dir /Users/miyashiiii/Works/myapp/myapp/.aws-sam/build
Building codeuri: myapp/ runtime: python3.7 metadata: {} functions: ['MyFunction']

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.7. Do you have python for runtime: python3.7 on your PATH?

python3.7 is on my PATH, and other some locations is on my PATH, but locations list includes only '/usr/bin/python'.

And when I do same command (/usr/local/bin/sam build ~~) on terminal, It succeed.

How to export PATH to "sam build" command?


回答1:


I solved the problem for python3.8 (same for python3.7 I suppose) by linking executable into /usr/local/bin

ln -sf /usr/local/opt/python@3.8/bin/python3.8 /usr/local/bin/

To find your python directory if installed by homebrew: brew info python@3.8

Also, you'd probably prefer running SAM inside a docker container (option sam build --use-container with CLI)

In pycharm:



来源:https://stackoverflow.com/questions/65180787/how-to-export-path-to-sam-build-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!