ImportError for packages.urllib3.poolmanager on Debian #82

Closed
stweller opened this Issue Jul 2, 2014 · 19 comments

Projects

None yet

7 participants

@stweller
stweller commented Jul 2, 2014

On a Debian system (very likely also Ubuntu) the version of requests is patched to not ship their own version of urllib, in other words: packages.urllib3 does not exist (same issue as e.g. here: mk-fg/python-onedrive#13. Hence, I get the following error:

Traceback (most recent call last):
  File "build/bdist.linux-x86_64/egg/vdirsyncer/cli.py", line 133, in storage_instance_from_config
    return cls(**config)
  File "build/bdist.linux-x86_64/egg/vdirsyncer/storage/dav.py", line 473, in __init__
    super(CaldavStorage, self).__init__(**kwargs)
  File "build/bdist.linux-x86_64/egg/vdirsyncer/storage/dav.py", line 264, in __init__
    useragent, dav_header=self.dav_header)
  File "build/bdist.linux-x86_64/egg/vdirsyncer/storage/dav.py", line 186, in __init__
    'auth': prepare_auth(auth, username, password)
  File "build/bdist.linux-x86_64/egg/vdirsyncer/storage/http.py", line 27, in prepare_auth
    import requests_toolbelt
  File "build/bdist.linux-x86_64/egg/requests_toolbelt/__init__.py", line 19, in <module>
  File "build/bdist.linux-x86_64/egg/requests_toolbelt/adapters/__init__.py", line 12, in <module>
  File "build/bdist.linux-x86_64/egg/requests_toolbelt/adapters/ssl.py", line 13, in <module>
ImportError: No module named packages.urllib3.poolmanager
@untitaker
Member

I can't do much about this, and i don't think any maintainers of the involved Python software should either; This is clearly a packaging issue, and the breakage is solely the responsibility of the package maintainer.

Unfortunately i also don't have a temporary fix other than avoiding Debian's packaging system by using pip install --user vdirsyncer and checking that requests gets reinstalled properly.

@untitaker untitaker closed this Jul 2, 2014
@untitaker
Member

I guess you can ask on the issuetracker for requests-toolbelt.

@stweller
stweller commented Jul 3, 2014

Thank you for the quick reply. Just for future reference: pip install --user vdirsyncer does not help, since python can then still uses the system version of requests (which is up to date).

@untitaker
Member

Yes, i realized that and added the "checking that requests gets reinstalled properly" a while after posting. Using a virtualenv might be the safest solution even (and symlinking env/bin/vdirsyncer into your path)

@xnox
xnox commented Jul 3, 2014

Debian maintainers chose not to ship requests.packages.urllib3 due to debian policies to avoid embedded copies of code and it is a deliberate, rather than accidental divergence. A bug report in debian has now been opened, requesting for requests.packages.urllib3 import to work, even if it's just a compat wrapper that imports python3-urllib3 package. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=753578 any further comments about this issue in the Debian package should go there.

@untitaker
Member

@xnox Thank you for the summary, i already linked the Debian bugreport further above. :)

@untitaker
Member

Please don't comment on this anymore, everybody who wants to discuss or subscribe should do so on Debian's bugtracker.

@untitaker untitaker locked and limited conversation to collaborators Jul 3, 2014
@jbremer jbremer referenced this issue in sigmavirus24/requests-toolbelt Sep 1, 2014
Closed

import from urllib3 directly if it has not been shipped #40

@untitaker
Member

Hmm, maybe i shouldn't have closed this. My aim was rather to centralize discussion, not prevent it.

@untitaker untitaker unlocked this conversation Sep 7, 2014
@untitaker untitaker reopened this Sep 7, 2014
@untitaker untitaker added the upstream label Sep 7, 2014
@untitaker untitaker added the Packaging label Sep 7, 2014
@eriol
eriol commented Oct 21, 2014

Fixed on unstable: https://packages.qa.debian.org/r/requests/news/20141021T100416Z.html
To backport it for Debian 7 I must wait that the package migrates into testing. If there are (as I hope) no RC bug requests 2.4.3-1 will migrate into testing in 10 days.

@untitaker
Member

Awesome, thanks!

@sigmavirus24

thanks @eriolv

@geier
Member
geier commented Oct 21, 2014

👯

@untitaker
Member

@stweller Does updating requests fix the issue?

@stweller

Yes, sorry for taking so long to reply. Thanks a lot! Closing.

@stweller stweller closed this Oct 27, 2014
@untitaker
Member

Added a note in the docs at 867148d

@untitaker
Member

@zwerfvogel Why did you delete this? It might be useful for some people, although I personally think the solution presented in vdirsyncer's docs is cleaner.

On 19 December 2014 15:22:09 CET, zwerfvogel notifications@github.com wrote:

Here is a patch for older versions:

diff --git a/requests_toolbelt/adapters/source.py
b/requests_toolbelt/adapters/source.py
index 841014e..329baae 100644
--- a/requests_toolbelt/adapters/source.py
+++ b/requests_toolbelt/adapters/source.py
@@ -7,7 +7,7 @@ This file contains an implementation of the
SourceAddressAdapter originally
demonstrated on the Requests GitHub page.
"""
from requests.adapters import HTTPAdapter
-from requests.packages.urllib3.poolmanager import PoolManager
+from urllib3.poolmanager import PoolManager


class SourceAddressAdapter(HTTPAdapter):
diff --git a/requests_toolbelt/adapters/ssl.py
b/requests_toolbelt/adapters/ssl.py
index e79107d..979e9f5 100644
--- a/requests_toolbelt/adapters/ssl.py
+++ b/requests_toolbelt/adapters/ssl.py
@@ -10,7 +10,7 @@
https://lukasa.co.uk/2013/01/Choosing_SSL_Version_In_Requests/

"""
from requests.adapters import HTTPAdapter
-from requests.packages.urllib3.poolmanager import PoolManager
+from urllib3.poolmanager import PoolManager


class SSLAdapter(HTTPAdapter):
diff --git a/requests_toolbelt/multipart/encoder.py
b/requests_toolbelt/multipart/encoder.py
index 7b46931..4ef52c1 100644
--- a/requests_toolbelt/multipart/encoder.py
+++ b/requests_toolbelt/multipart/encoder.py
@@ -9,7 +9,7 @@ This holds all of the implementation details of the
MultipartEncoder
"""

from requests.utils import super_len
-from requests.packages.urllib3.filepost import iter_field_objects
+from urllib3.filepost import iter_field_objects
from uuid import uuid4

import contextlib

Reply to this email directly or view it on GitHub:
#82 (comment)

@zwerfvogel

I read the surrounding discussion regarding the Debian packaging decisions, then saw the unmerged pull request sigmavirus24/requests-toolbelt#40 here which implements exactly what I did but better and decided no-one would want my patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment