How do I add python libraries to an AWS lambda function for Alexa?

0 votes

I was following the tutorial to create an Alexa app using Python:

Python Alexa Tutorial

I was able to successfully follow all the steps and get the app to work. I now want to modify the python code and use external libraries such as import requests
or any other libraries that I install using pip. How would I set up my lambda function to include any pip packages that I install locally on my machine?

Oct 23, 2018 in AWS by datageek
• 2,500 points
7,586 views

2 answers to this question.

0 votes

As it is described in the Amazon official documentation link here It is as simple as just creating a zip of all the folder contents after installing the required packages in your folder where you have your python lambda code.

The very first step in moving from an inline code editor to a zip file upload approach is to change your lambda function handler name under configuration settings to include the python script filename that holds the lambda handler.

Other solutions like python-lambda and lambda-uploader help with simplifying the process of uploading and the most importantly LOCAL TESTING. These will save a lot of time in development.

answered Oct 23, 2018 by Archana
• 4,150 points
+1 vote
If you get lucky (it depends what packages you're trying to upload) here's a simple method: https://medium.com/@melissa_89553/how-to-import-python-packages-in-aws-lambda-pandas-scipy-numpy-bb2c98c974e9

If that doesn't work for your specific package, you might need to do what's described here: https://medium.com/@korniichuk/lambda-with-pandas-fd81aa2ff25e or a more complicated docker solution.
answered Nov 3 by anonymous

Related Questions In AWS

0 votes
1 answer
0 votes
2 answers

How do I define the principal for an AWS policy statement?

Check with AWS Policy Documentations once, rest ...READ MORE

answered Jun 25, 2018 in AWS by Cloud gunner
• 4,650 points

edited Jun 26, 2018 by Cloud gunner 313 views
0 votes
1 answer
0 votes
1 answer

How to setup an alarm when Lambda function fails in AWS?

Hi@akhtar, To create an Alarm for Lambda function, ...READ MORE

answered Apr 2 in AWS by MD
• 80,750 points
379 views
0 votes
1 answer

how to get the list of aws services i am used in aws my account by using the lambda function

Hi@shalk, You can create a session in your ...READ MORE

answered Sep 24 in AWS by MD
• 80,750 points
56 views
0 votes
1 answer

How to add permissions to an existing Lambda function?

Hi@akhtar, You can grant an AWS service or another ...READ MORE

answered Nov 5 in AWS by MD
• 80,750 points
25 views
+1 vote
2 answers

How do I run python script on aws EC2 instance(ubuntu)?

I believe that you are using the ...READ MORE

answered Apr 17, 2018 in AWS by Cloud gunner
• 4,650 points
6,490 views
0 votes
1 answer

How do I invoke another lambda async and pass context to it?

I tried several times trying to pass ...READ MORE

answered Apr 27, 2018 in AWS by Cloud gunner
• 4,650 points
4,381 views
0 votes
2 answers