I imported boto3
for my lambda function in python. When i test lambda it gives this error : No module named boto3
which is rather expected.
Then i
You need to make a folder in your local system, install the required libraries into that folder, zip the contents of the folder and upload the zipped file to the AWS Lambda.
I don't think you need help in this. Lets suppose you made a folder in D drive named yellow-bot
You can install the required packages in the folder using below command
pip install {package-name} -t "{path-to-project-dir}"
In your case it would be:
pip install apiai -t "D:\yellow-bot"
Now after installing the required libraries there will be multiple files and folders in your yellow-bot folder. You need to select all and zip the content. Please note that do not zip the folder, instead you go inside the folder and zip the contents.
It would be something like below screenshot.
Now go to AWS Lambda, create a lambda function, give correct run-time and all that. Then select upload zip
file in code entry type
. Select your zip and click on upload.
Make sure to give correct Handler
.
It follows naming convention as:
The filename.handler-method value in your function. For example, "main.handler" would call the handler method defined in main.py.
Since in this case I have uploaded connector.py
file and entry function was called lambda_handler()
so correct Handler
would be connector.lambda_handler
Click on Save
and you are done.
Hope it helps.