Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requests-toolbelt <1 not compatible with urllib3 v2 #8679

Closed
4 tasks done
hugovk opened this issue Nov 16, 2023 · 3 comments · Fixed by #8680
Closed
4 tasks done

requests-toolbelt <1 not compatible with urllib3 v2 #8679

hugovk opened this issue Nov 16, 2023 · 3 comments · Fixed by #8680
Labels
kind/bug Something isn't working as expected

Comments

@hugovk
Copy link
Contributor

hugovk commented Nov 16, 2023

  • Poetry version: 1.7.0
  • Python version: 3.11.5
  • OS version and name: macOS 13.6
  • pyproject.toml: n/a
  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

If you already have requests-toolbelt < 1 installed, it's incompatible with urllib3 v2.

I suggest bumping the minimum requests-toolbelt version to v1.

Fresh install, with latest requests-toolbelt 1.0.0

$ rm -rf venv
$ python -m venv venv
$ venv/bin/python3 -m pip install poetry
...
$ venv/bin/python3 -m pip freeze
build==1.0.3
CacheControl==0.13.1
certifi==2023.7.22
cffi==1.16.0
charset-normalizer==3.3.2
cleo==2.1.0
crashtest==0.4.1
distlib==0.3.7
dulwich==0.21.6
fastjsonschema==2.19.0
filelock==3.13.1
idna==3.4
importlib-metadata==6.8.0
installer==0.7.0
jaraco.classes==3.3.0
keyring==24.3.0
more-itertools==10.1.0
msgpack==1.0.7
packaging==23.2
pexpect==4.8.0
pkginfo==1.9.6
platformdirs==3.11.0
poetry==1.7.0
poetry-core==1.8.1
poetry-plugin-export==1.6.0
ptyprocess==0.7.0
pycparser==2.21
pyproject_hooks==1.0.0
rapidfuzz==3.5.2
requests==2.31.0
requests-toolbelt==1.0.0
shellingham==1.5.4
tomlkit==0.12.3
trove-classifiers==2023.11.14
urllib3==2.1.0
virtualenv==20.24.6
xattr==0.10.1
zipp==3.17.0
$ venv/bin/python3 -m poetry init

This command will guide you through creating your pyproject.toml config.

Package name [poetry-test]:
...

Other poetry commands work fine.

With requests-toolbelt < 1 already installed

$ rm -rf venv
$ python -m venv venv
$ venv/bin/python3 -m pip install "requests-toolbelt<1"
...
$ venv/bin/python3 -m pip install poetry
...
$ venv/bin/python3 -m pip freeze
build==1.0.3
CacheControl==0.13.1
certifi==2023.7.22
cffi==1.16.0
charset-normalizer==3.3.2
cleo==2.1.0
crashtest==0.4.1
distlib==0.3.7
dulwich==0.21.6
fastjsonschema==2.19.0
filelock==3.13.1
idna==3.4
importlib-metadata==6.8.0
installer==0.7.0
jaraco.classes==3.3.0
keyring==24.3.0
more-itertools==10.1.0
msgpack==1.0.7
packaging==23.2
pexpect==4.8.0
pkginfo==1.9.6
platformdirs==3.11.0
poetry==1.7.0
poetry-core==1.8.1
poetry-plugin-export==1.6.0
ptyprocess==0.7.0
pycparser==2.21
pyproject_hooks==1.0.0
rapidfuzz==3.5.2
requests==2.31.0
requests-toolbelt==0.10.1
shellingham==1.5.4
tomlkit==0.12.3
trove-classifiers==2023.11.14
urllib3==2.1.0
virtualenv==20.24.6
xattr==0.10.1
zipp==3.17.0
$ venv/bin/python3 -m poetry init
Traceback (most recent call last):
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/requests_toolbelt/_compat.py", line 48, in <module>
    from requests.packages.urllib3.contrib import appengine as gaecontrib
ImportError: cannot import name 'appengine' from 'requests.packages.urllib3.contrib' (/private/tmp/poetry-test/venv/lib/python3.11/site-packages/urllib3/contrib/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/cleo/application.py", line 327, in run
    exit_code = self._run(io)
                ^^^^^^^^^^^^^
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/console/application.py", line 188, in _run
    self._load_plugins(io)
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/console/application.py", line 354, in _load_plugins
    manager.load_plugins()
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/plugins/plugin_manager.py", line 38, in load_plugins
    self._load_plugin_entry_point(ep)
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/plugins/plugin_manager.py", line 76, in _load_plugin_entry_point
    plugin = ep.load()  # type: ignore[no-untyped-call]
             ^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/metadata/__init__.py", line 202, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry_plugin_export/plugins.py", line 7, in <module>
    from poetry_plugin_export.command import ExportCommand
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry_plugin_export/command.py", line 12, in <module>
    from poetry_plugin_export.exporter import Exporter
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry_plugin_export/exporter.py", line 11, in <module>
    from poetry.repositories.http_repository import HTTPRepository
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/repositories/http_repository.py", line 26, in <module>
    from poetry.utils.authenticator import Authenticator
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/utils/authenticator.py", line 22, in <module>
    from requests_toolbelt import user_agent
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/requests_toolbelt/__init__.py", line 12, in <module>
    from .adapters import SSLAdapter, SourceAddressAdapter
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/requests_toolbelt/adapters/__init__.py", line 12, in <module>
    from .ssl import SSLAdapter
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/requests_toolbelt/adapters/ssl.py", line 16, in <module>
    from .._compat import poolmanager
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/requests_toolbelt/_compat.py", line 50, in <module>
    from urllib3.contrib import appengine as gaecontrib
ImportError: cannot import name 'appengine' from 'urllib3.contrib' (/private/tmp/poetry-test/venv/lib/python3.11/site-packages/urllib3/contrib/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/requests_toolbelt/_compat.py", line 48, in <module>
    from requests.packages.urllib3.contrib import appengine as gaecontrib
ImportError: cannot import name 'appengine' from 'requests.packages.urllib3.contrib' (/private/tmp/poetry-test/venv/lib/python3.11/site-packages/urllib3/contrib/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/__main__.py", line 9, in <module>
    sys.exit(main())
             ^^^^^^
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/console/application.py", line 411, in main
    exit_code: int = Application().run()
                     ^^^^^^^^^^^^^^^^^^^
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/cleo/application.py", line 338, in run
    self.render_error(e, io)
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/console/application.py", line 180, in render_error
    self.set_solution_provider_repository(self._get_solution_provider_repository())
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/console/application.py", line 400, in _get_solution_provider_repository
    from poetry.mixology.solutions.providers.python_requirement_solution_provider import (
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/mixology/solutions/providers/__init__.py", line 3, in <module>
    from poetry.mixology.solutions.providers.python_requirement_solution_provider import (
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/mixology/solutions/providers/python_requirement_solution_provider.py", line 9, in <module>
    from poetry.puzzle.exceptions import SolverProblemError
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/puzzle/__init__.py", line 3, in <module>
    from poetry.puzzle.solver import Solver
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/puzzle/solver.py", line 16, in <module>
    from poetry.puzzle.provider import Indicator
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/puzzle/provider.py", line 27, in <module>
    from poetry.packages.direct_origin import DirectOrigin
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/packages/direct_origin.py", line 14, in <module>
    from poetry.vcs.git import Git
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/vcs/git/__init__.py", line 3, in <module>
    from poetry.vcs.git.backend import Git
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/vcs/git/backend.py", line 25, in <module>
    from poetry.utils.authenticator import get_default_authenticator
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/utils/authenticator.py", line 22, in <module>
    from requests_toolbelt import user_agent
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/requests_toolbelt/__init__.py", line 12, in <module>
    from .adapters import SSLAdapter, SourceAddressAdapter
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/requests_toolbelt/adapters/__init__.py", line 12, in <module>
    from .ssl import SSLAdapter
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/requests_toolbelt/adapters/ssl.py", line 16, in <module>
    from .._compat import poolmanager
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/requests_toolbelt/_compat.py", line 50, in <module>
    from urllib3.contrib import appengine as gaecontrib
ImportError: cannot import name 'appengine' from 'urllib3.contrib' (/private/tmp/poetry-test/venv/lib/python3.11/site-packages/urllib3/contrib/__init__.py)

Same thing with other poetry commands.

The only difference in pip freeze is the requests-toolbelt version.

And again in debug mode

As requested by the issue template. Output looks the same because the exception happens immediately, but I didn't compare in detail.

Details
$ venv/bin/python3 -m poetry init -vvv
Traceback (most recent call last):
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/requests_toolbelt/_compat.py", line 48, in <module>
    from requests.packages.urllib3.contrib import appengine as gaecontrib
ImportError: cannot import name 'appengine' from 'requests.packages.urllib3.contrib' (/private/tmp/poetry-test/venv/lib/python3.11/site-packages/urllib3/contrib/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/cleo/application.py", line 327, in run
    exit_code = self._run(io)
                ^^^^^^^^^^^^^
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/console/application.py", line 188, in _run
    self._load_plugins(io)
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/console/application.py", line 354, in _load_plugins
    manager.load_plugins()
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/plugins/plugin_manager.py", line 38, in load_plugins
    self._load_plugin_entry_point(ep)
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/plugins/plugin_manager.py", line 76, in _load_plugin_entry_point
    plugin = ep.load()  # type: ignore[no-untyped-call]
             ^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/metadata/__init__.py", line 202, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry_plugin_export/plugins.py", line 7, in <module>
    from poetry_plugin_export.command import ExportCommand
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry_plugin_export/command.py", line 12, in <module>
    from poetry_plugin_export.exporter import Exporter
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry_plugin_export/exporter.py", line 11, in <module>
    from poetry.repositories.http_repository import HTTPRepository
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/repositories/http_repository.py", line 26, in <module>
    from poetry.utils.authenticator import Authenticator
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/utils/authenticator.py", line 22, in <module>
    from requests_toolbelt import user_agent
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/requests_toolbelt/__init__.py", line 12, in <module>
    from .adapters import SSLAdapter, SourceAddressAdapter
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/requests_toolbelt/adapters/__init__.py", line 12, in <module>
    from .ssl import SSLAdapter
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/requests_toolbelt/adapters/ssl.py", line 16, in <module>
    from .._compat import poolmanager
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/requests_toolbelt/_compat.py", line 50, in <module>
    from urllib3.contrib import appengine as gaecontrib
ImportError: cannot import name 'appengine' from 'urllib3.contrib' (/private/tmp/poetry-test/venv/lib/python3.11/site-packages/urllib3/contrib/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/requests_toolbelt/_compat.py", line 48, in <module>
    from requests.packages.urllib3.contrib import appengine as gaecontrib
ImportError: cannot import name 'appengine' from 'requests.packages.urllib3.contrib' (/private/tmp/poetry-test/venv/lib/python3.11/site-packages/urllib3/contrib/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/__main__.py", line 9, in <module>
    sys.exit(main())
             ^^^^^^
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/console/application.py", line 411, in main
    exit_code: int = Application().run()
                     ^^^^^^^^^^^^^^^^^^^
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/cleo/application.py", line 338, in run
    self.render_error(e, io)
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/console/application.py", line 180, in render_error
    self.set_solution_provider_repository(self._get_solution_provider_repository())
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/console/application.py", line 400, in _get_solution_provider_repository
    from poetry.mixology.solutions.providers.python_requirement_solution_provider import (
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/mixology/solutions/providers/__init__.py", line 3, in <module>
    from poetry.mixology.solutions.providers.python_requirement_solution_provider import (
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/mixology/solutions/providers/python_requirement_solution_provider.py", line 9, in <module>
    from poetry.puzzle.exceptions import SolverProblemError
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/puzzle/__init__.py", line 3, in <module>
    from poetry.puzzle.solver import Solver
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/puzzle/solver.py", line 16, in <module>
    from poetry.puzzle.provider import Indicator
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/puzzle/provider.py", line 27, in <module>
    from poetry.packages.direct_origin import DirectOrigin
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/packages/direct_origin.py", line 14, in <module>
    from poetry.vcs.git import Git
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/vcs/git/__init__.py", line 3, in <module>
    from poetry.vcs.git.backend import Git
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/vcs/git/backend.py", line 25, in <module>
    from poetry.utils.authenticator import get_default_authenticator
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/poetry/utils/authenticator.py", line 22, in <module>
    from requests_toolbelt import user_agent
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/requests_toolbelt/__init__.py", line 12, in <module>
    from .adapters import SSLAdapter, SourceAddressAdapter
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/requests_toolbelt/adapters/__init__.py", line 12, in <module>
    from .ssl import SSLAdapter
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/requests_toolbelt/adapters/ssl.py", line 16, in <module>
    from .._compat import poolmanager
  File "/private/tmp/poetry-test/venv/lib/python3.11/site-packages/requests_toolbelt/_compat.py", line 50, in <module>
    from urllib3.contrib import appengine as gaecontrib
ImportError: cannot import name 'appengine' from 'urllib3.contrib' (/private/tmp/poetry-test/venv/lib/python3.11/site-packages/urllib3/contrib/__init__.py)
@hugovk hugovk added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Nov 16, 2023
@hugovk
Copy link
Contributor Author

hugovk commented Nov 16, 2023

Reason why requests-toolbelt 1.0.0 is needed:

1.0.0 -- 2023-05-01

Breaking Changes

Removed Google App Engine support to allow using urllib3 2.0

https://github.com/requests/toolbelt/blob/master/HISTORY.rst#100----2023-05-01

@Telofy
Copy link

Telofy commented Feb 6, 2024

Oddly enough, I had to manually upgrade with pip3.11 install requests-toolbelt -U after installing Poetry. Just in case anyone else runs into the same problem.

@abn abn removed the status/triage This issue needs to be triaged label Mar 2, 2024
Copy link

github-actions bot commented Apr 2, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants