If the version of pip inside SAM and the version of local pip do not match, it may not work, so you need to modify the version of local pip.
item name | version |
---|---|
OS | MacOS High Sierra 10.13.6 |
VSCode | 1.40.2 |
SAM | 0.37.0 |
Python | 3.7.3 |
pip | 19.3.1(19 in the article.2.Change to 3) |
It may not work when you want to test in a local environment using the AWS Toolkit from VS Code's "Run Locally". For example, the following error.
Local invoke of SAM Application has ended.
Preparing to run app.lambda_handler locally...
Building SAM Application...
An error occurred trying to run SAM Application locally: Error with child process: Building resource 'awsToolkitSamLocalResource'
,Running PythonPipBuilder:ResolveDependencies
,Error: PythonPipBuilder:ResolveDependencies - Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: 'module' object is not callable
It seems that the issue that occurred in SAM has not been solved yet in VS Code's AWS Toolkit. GitHub : sam build fails for python3.7 functions with pip==19.3 installed If you try the same settings and execute the following command from the terminal, there is no problem even if the verison of SAM and pip are the same.
$ sam local invoke HelloWorldFunction --event events/event.json
Although it is a temporary measure, if you modify the version of pip to the following, it will be possible to execute normally even from VS Code.
$ pip install pip==19.2.3
Log "Run Locally" from VS Code after changing pip version
Fetching lambci/lambda:python3.7 Docker container image......
Mounting /tmp/aws-toolkit-vscode/vsctkytL1AY/output/awsToolkitSamLocalResource as /var/task:ro,delegated inside runtime container
...(Omission)...
{"statusCode":200,"body":"{\"message\": \"hello worldXXX\"}"}
Recommended Posts