问题描述
我正在PyCharm上开发AWS Lambda函数.当我执行运行"时,按钮,出现以下错误消息.
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在我的PATH上,其他一些位置在我的PATH上,但是位置列表仅包含'/usr/bin/python'.
python3.7 is on my PATH, and other some locations is on my PATH, but locations list includes only '/usr/bin/python'.
当我在终端上执行相同的命令(/usr/local/bin/sam build ~~)时,它成功了.
And when I do same command (/usr/local/bin/sam build ~~) on terminal, It succeed.
如何将PATH导出到"sam build"命令?
How to export PATH to "sam build" command?
推荐答案
我通过将可执行文件链接到/usr/local/bin来解决了python3.8的问题(我想与python3.7相同)
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/[email protected]/bin/python3.8 /usr/local/bin/
要查找由homebrew安装的python目录,请执行以下操作: brew info [email protected]
To find your python directory if installed by homebrew: brew info [email protected]
此外,您可能更希望在docker容器中运行SAM(带有CLI的选项 sam build --use-container
)
Also, you'd probably prefer running SAM inside a docker container (option sam build --use-container
with CLI)
在pycharm中:
In pycharm:
这篇关于如何将PATH导出到"sam build"?命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!