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,540 points
15,539 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.

Hope this helps!!

If you need to know more about Python, join Python online course today.

Thanks!

answered Oct 23, 2018 by Archana
• 4,170 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, 2020 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 26, 2018 in AWS by Cloud gunner
• 4,670 points

edited Jun 26, 2018 by Cloud gunner 1,157 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, 2020 in AWS by MD
• 95,460 points
4,176 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, 2020 in AWS by MD
• 95,460 points
2,456 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, 2020 in AWS by MD
• 95,460 points
2,221 views
0 votes
0 answers
0 votes
2 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP