error pip install -t python requests

0

Hi I get this error running this command

pip install -t python requests Collecting requests Using cached requests-2.32.3-py3-none-any.whl (64 kB) Collecting certifi>=2017.4.17 Using cached certifi-2024.12.14-py3-none-any.whl (164 kB) Collecting urllib3<3,>=1.21.1 Using cached urllib3-2.3.0-py3-none-any.whl (128 kB) Collecting idna<4,>=2.5 Using cached idna-3.10-py3-none-any.whl (70 kB) Collecting charset-normalizer<4,>=2 Using cached charset_normalizer-3.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (146 kB) Installing collected packages: urllib3, idna, charset-normalizer, certifi, requests ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. botocore 1.35.97 requires urllib3<1.27,>=1.25.4; python_version < "3.10", but you have urllib3 2.3.0 which is incompatible. Successfully installed certifi-2024.12.14 charset-normalizer-3.4.1 idna-3.10 requests-2.32.3 urllib3-2.3.0 [cloudshell-user@ip-10-132-36-162 python]$

ERROR STARTS ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. botocore 1.35.97 requires urllib3<1.27,>=1.25.4; python_version < "3.10", but you have urllib3 2.3.0 which is incompatible.

ERROR END

I want some help to get this fixed

2 Answers
1

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

profile pictureAWS
EXPERT
answered 24 days ago
profile picture
EXPERT
reviewed 24 days ago
0

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:

  1. 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.

  1. 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

  2. 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.

  3. 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.

  4. 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

profile picture
answered 25 days ago
profile picture
EXPERT
reviewed 24 days 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.

Guidelines for Answering Questions