Response:
{
"errorMessage": "Unable to import module 'lambda_function'"
}
Unable to import module 'lambda_function': No module named 'plivo'
- Download the Twilio Library on Ubuntu machine using the command (with
sudo pip3 install plivo-t
) and ZIP the Twilio library. - The libraries add to layers and connected to current Lambda function. Please find my lambda function code in above image.
- When I test the function shows error like as "Unable to import module 'lambda_function': No module named 'plivo'". Please find the execution result in the above image.
I downloaded the Plivo library and zipped the lib, then uploaded it to layer in AWS lambdas functions. I connected the layer to current functions, then when I test the function, it shows an error like "Unable to import module 'lambda_function': No module named 'plivo '".
Code:
import json
import requests
import plivo
#from twilio.rest import Client #I added Layers. That is twilios library zi
def lambda_handler(event, context):
return {'statusCode': 200, 'body': json.dumps('Hello from Lambda!') }
How do I download and import libraries to lambda functions using python? Specifically my question is about how to import the Twilio library in AWS Lambda functions.