- Newest
- Most votes
- Most comments
HI,
It seems that your Lambda runtime is an old version of Python (it seems to be 3.9)
Update to a more recent version of Python for Lambda (I personally use 3.12) and then you should be able to use a recent version of urllib3 like 2.3.0.
See https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html for supported Lambda runtime versions,
Best,
Didier
The error you're encountering is due to a version conflict between the urllib3 package required by botocore and the version being installed by your pip command. Here's how you can address this issue:
-
First, try specifying the compatible version of urllib3 when installing requests:
pip install -t python requests "urllib3<1.27"
This should install a version of urllib3 that's compatible with both requests and botocore.
-
If that doesn't work, you may need to update botocore to a version that's compatible with the newer urllib3. You can do this by running:
pip install -U botocore
-
If you're working in a Lambda function or similar environment where you need to package dependencies, consider creating a virtual environment and installing your dependencies there. This can help isolate your project's dependencies from system-wide packages.
-
Another option is to use a requirements.txt file to specify exact versions of all dependencies, including transitive ones. This can help ensure consistency across different environments.
-
If you're working on an AWS service like Lambda, you might consider using Lambda Layers to manage your dependencies separately from your function code.
Remember that when working with AWS services, it's important to ensure all your dependencies are compatible with the service and runtime you're using. Always test your setup thoroughly after making changes to dependencies.
Sources
Unable to import module pollingLambdaHandler: No module named 'requests' | AWS re:Post
Amazon MWAA best practices for managing Python dependencies | AWS Big Data Blog
Relevant content
- asked 6 years ago
- asked 3 years ago
- AWS OFFICIALUpdated 2 years ago
- How do I install and troubleshoot Python libraries in Amazon EMR and Amazon EMR Serverless clusters?AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated 6 months ago