requests / toolbelt

A toolbelt of useful classes and functions to be used with python-requests
https://toolbelt.readthedocs.org
Other
989 stars 186 forks source link

dependency problem with urllib3>=2.0.0 #366

Closed ds21194 closed 1 year ago

ds21194 commented 1 year ago

I'm trying to use this lib (toolbelt) with AWS lambda, and apparently boto3 does not support urllib3>=2.0.0:

https://stackoverflow.com/questions/76414514/cannot-import-name-default-ciphers-from-urllib3-util-ssl-on-aws-lambda-us Throwing the error in the link.

Is there a version of this lib that uses a lower version of urllib3, so I won't have this dependency colission? Thanks!

pquentin commented 1 year ago

Hello, as far as I can tell, this library supports urllib3 1.26.x. Please reopen if you have evidence of the contrary.

ds21194 commented 1 year ago

Maybe I'm doing something wrong, but this is how I'm creating the AWS Layer:

`docker run -v "$PWD":/var/task "public.ecr.aws/sam/build-python3.9" /bin/sh -c "pip install -r requirements.txt -t logs:

`python/lib/python3.9/site-packages/; exit"
Collecting urllib3==1.26.7
  Downloading urllib3-1.26.7-py2.py3-none-any.whl (138 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 138.8/138.8 KB 921.0 kB/s eta 0:00:00
Collecting requests-toolbelt==0.10.1
  Downloading requests_toolbelt-0.10.1-py2.py3-none-any.whl (54 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 54.5/54.5 KB 1.7 MB/s eta 0:00:00
Collecting requests<3.0.0,>=2.0.1
  Downloading requests-2.31.0-py3-none-any.whl (62 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.6/62.6 KB 5.1 MB/s eta 0:00:00
Collecting certifi>=2017.4.17
  Downloading certifi-2023.5.7-py3-none-any.whl (156 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 157.0/157.0 KB 6.5 MB/s eta 0:00:00
Collecting charset-normalizer<4,>=2
  Downloading charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (199 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 199.2/199.2 KB 10.2 MB/s eta 0:00:00
Collecting idna<4,>=2.5
  Downloading idna-3.4-py3-none-any.whl (61 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 KB 9.9 MB/s eta 0:00:00

and I'm still getting this error: [ERROR] Runtime.ImportModuleError: Unable to import module 'post_messages': cannot import name 'DEFAULT_CIPHERS' from 'urllib3.util.ssl_' (/opt/python/lib/python3.9/site-packages/urllib3/util/ssl_.py)

I even tried to install with pip install --force-reinstall -v -r requirements.txt -t python/lib/python3.9/site-packages/; to make sure the right version of urlib3 is installed.

Worth to mention that when I installed only urlib3 1.26.7 this behavior didn't happen.

What do you think? @pquentin BTW- it happened both with versions 1.0.0 and 0.10.1, didn't check more.

pquentin commented 1 year ago

Can you please post the full traceback, not just the cannot import name 'DEFAULT_CIPHERS' line? Nothing is pointing to requests-toolbelt right now.

ds21194 commented 1 year ago

You are right, I found the issue. I didn't notice my boto3 lib was outdated (3.10 instead of 3.27) Thanks for the help, much appreciation