Skip to content

Unable to import module pollingLambdaHandler: No module named 'requests'

0

I'm getting the above error when importing requests in my lambda function (Python).

I am following this guide, which instructed to "pip install requests". https://docs.aws.amazon.com/neptune/latest/userguide/iam-auth-connecting-python.html

Upon installing requests, I see: Requirement already satisfied: requests in /Users/.../env/lib/python3.8/site-packages (2.32.3) Requirement already satisfied: charset-normalizer<4,>=2 in /Users/.../env/lib/python3.8/site-packages (from requests) (3.3.2) Requirement already satisfied: idna<4,>=2.5 in /Users/.../env/lib/python3.8/site-packages (from requests) (3.7) Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/.../env/lib/python3.8/site-packages (from requests) (2.2.2) Requirement already satisfied: certifi>=2017.4.17 in /Users/.../env/lib/python3.8/site-packages (from requests) (2024.6.2)

I am aware of the layers-solution, however prefer to avoid it and follow the steps in the guide linked above.

1 Answer
1

Hello.

You cannot use "request" in Lambda just by running "pip install request" on your local PC.
You need to create a Lambda layer or upload a "request" module along with your Lambda function code.
https://docs.aws.amazon.com/lambda/latest/dg/python-layers.html

EXPERT
answered a year ago
EXPERT
reviewed a year ago
EXPERT
reviewed a year ago
EXPERT
reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.