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

[BUG] Python 3.10, requests-toolbelt, & Google App Engine vs urllib3 2.0 #9

Open
Fenikkusu opened this issue Aug 14, 2023 · 0 comments

Comments

@Fenikkusu
Copy link

Documenting this here for future reference. I've been working on an 'odd' project where I am repurposing a 2014 MacMini as a replacement for a Raspberry PI to run Klipper + Moonraker + KlipperScreen + OctoPrint + RaiseCloud. I used Kiauh to install everything and found that while my printers were working, OctoPrint was having an issue loading the RaiseCloud plugin. I checked my octoprint.log file and saw the below error in the logs:

2023-08-13 17:01:28,283 - octoprint.plugin.core - ERROR - Error loading plugin raisecloud
Traceback (most recent call last):
  File "/OctoPrint_Tevo/venv/lib/python3.10/site-packages/octoprint/plugin/core.py", line 1294, in _import_plugin
    module = _load_module(module_name, spec)
  File "/OctoPrint_Tevo/venv/lib/python3.10/site-packages/octoprint/plugin/core.py", line 52, in _load_module
    return imp.load_module(name, f, filename, details)
  File "/OctoPrint_Tevo/venv/lib/python3.10/site-packages/octoprint/vendor/imp.py", line 238, in load_module
    return load_package(name, filename)
  File "/OctoPrint_Tevo/venv/lib/python3.10/site-packages/octoprint/vendor/imp.py", line 212, in load_package
    return _load(spec)
  File "<frozen importlib._bootstrap>", line 719, in _load
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/OctoPrint_Tevo/venv/lib/python3.10/site-packages/octoprint_raisecloud/__init__.py", line 12, in <module>
    from .cloud_task import CloudTask
  File "/OctoPrint_Tevo/venv/lib/python3.10/site-packages/octoprint_raisecloud/cloud_task.py", line 11, in <module>
    from .webcam import webcam_instance
  File "/OctoPrint_Tevo/venv/lib/python3.10/site-packages/octoprint_raisecloud/webcam.py", line 13, in <module>
    from requests_toolbelt import MultipartEncoder
  File "/OctoPrint_Tevo/venv/lib/python3.10/site-packages/requests_toolbelt/__init__.py", line 12, in <module>
    from .adapters import SSLAdapter, SourceAddressAdapter
  File "/OctoPrint_Tevo/venv/lib/python3.10/site-packages/requests_toolbelt/adapters/__init__.py", line 12, in <module>
    from .ssl import SSLAdapter
  File "/OctoPrint_Tevo/venv/lib/python3.10/site-packages/requests_toolbelt/adapters/ssl.py", line 16, in <module>
    from .._compat import poolmanager
  File "/OctoPrint_Tevo/venv/lib/python3.10/site-packages/requests_toolbelt/_compat.py", line 11, in <module>
    from collections import Mapping, MutableMapping

Initially, I tried modifying /OctoPrint_Tevo/venv/lib/python3.10/site-packages/requests_toolbelt/_compat.py and changing the line to say from collections.abc import Mapping, MutableMapping and this got rid of that error, leading to the error ImportError: cannot import name 'appengine' from 'requests.packages.urllib3.contrib'

After a bit more digging, I learned that this has to do with urlib3 not being compatible with requests_toolbox. It turns out that in requests_toolbox 1.0.0, this was resolved because the Google App Engine was removed so urlib3 would work correctly.

In order to resolve this, I ran bin/python3.10 bin/pip install requests-toolbelt==1.0.0 from /OctoPrint_Tevo/venv and restarted OctoPrint. Afterward, the errors were gone and everything appears to be working as expected. So far, I've had no apparent issues.

At this point, the package version needs to be updated in the main repo. However, I don't know what adverse effects that may have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant