Skip to content

ImportError for packages.urllib3.poolmanager on Debian #82

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

Closed
ghost opened this issue Jul 2, 2014 · 19 comments
Closed

ImportError for packages.urllib3.poolmanager on Debian #82

ghost opened this issue Jul 2, 2014 · 19 comments

Comments

@ghost
Copy link

ghost 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
Copy link
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
Copy link
Member

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

@untitaker
Copy link
Member

@ghost
Copy link
Author

ghost 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
Copy link
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
Copy link

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
Copy link
Member

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

@eriol
Copy link

eriol commented Jul 3, 2014

@untitaker
Copy link
Member

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

@pimutils pimutils locked and limited conversation to collaborators Jul 3, 2014
@untitaker
Copy link
Member

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

@eriol
Copy link

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
Copy link
Member

Awesome, thanks!

@sigmavirus24
Copy link

thanks @EriolV

@geier
Copy link
Member

geier commented Oct 21, 2014

👯

@untitaker
Copy link
Member

@stweller Does updating requests fix the issue?

@ghost
Copy link
Author

ghost commented Oct 27, 2014

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

@ghost ghost closed this as completed Oct 27, 2014
@untitaker
Copy link
Member

Added a note in the docs at 867148d

@untitaker
Copy link
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
Copy link

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

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

No branches or pull requests

6 participants