Repository: docker/docker-py

Issue:
Failure to import requests.packages.urllib3.connectionpool
With requests 1.2.3 (the version which gets installed), this happens.

Workaround: use requests 1.2.0.

``` ipython
$ pip install --user docker-py
Downloading/unpacking docker-py
  Downloading docker-py-0.1.5.tar.gz
  Running setup.py egg_info for package docker-py

Requirement already satisfied (use --upgrade to upgrade): requests in /usr/lib/python2.7/dist-packages (from docker-py)
Requirement already satisfied (use --upgrade to upgrade): six in /usr/lib/python2.7/dist-packages (from docker-py)
Installing collected packages: docker-py
  Running setup.py install for docker-py

Successfully installed docker-py
Cleaning up...
pwaller@fractal:~$ ipython
imporPython 2.7.5+ (default, Jun  5 2013, 10:40:07) 
Type "copyright", "credits" or "license" for more information.

IPython 1.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import docker
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-3ac1c348f58a> in <module>()
----> 1 import docker

/home/pwaller/.local/lib/python2.7/site-packages/docker/__init__.py in <module>()
----> 1 from .client import Client

/home/pwaller/.local/lib/python2.7/site-packages/docker/client.py in <module>()
     15 from requests.exceptions import HTTPError
     16 from requests.adapters import HTTPAdapter
---> 17 from requests.packages.urllib3.connectionpool import HTTPConnectionPool
     18 
     19 if six.PY3:

ImportError: No module named packages.urllib3.connectionpool

In [2]: 
```



Discussion:
I couldn't reproduce this. Can you give more information about your setup so we can figure out what's happening?

```
# pip freeze | grep requests
requests==1.2.3
# ipython 
Python 2.7.4 (default, Apr 19 2013, 18:28:01) 
Type "copyright", "credits" or "license" for more information.

IPython 0.13.2 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import docker

In [2]:
```

I suppose requests was coming from my system, which is an Ubuntu 13.10 daily image. [Link to the source of said package](http://packages.ubuntu.com/saucy/python-requests).

Have you tried force-installing the suggested version through pip (i.e. `pip install -U requests==1.2.3`) ? 

@shin: it is version `requests==1.2.3`, so pip does nothing. It's just that the debian/ubuntu maintainers, in their wisdom, made it so that `requests` gets its `urllib3` from the system and not from its `requests.packages`. Is it possible for you to instead depend on `urllib3` or is there a strong reason to use something which is really an internal detail of `requests`?


Resolving patch:
diff --git a/docker/unixconn.py b/docker/unixconn.py
--- a/docker/unixconn.py
+++ b/docker/unixconn.py
@@ -14,10 +14,12 @@
 
 import httplib
 import requests.adapters
-import requests.packages.urllib3.connectionpool
 import socket
 
-HTTPConnectionPool = requests.packages.urllib3.connectionpool.HTTPConnectionPool
+try:
+    import requests.packages.urllib3.connectionpool as connectionpool
+except ImportError:
+    import urllib3.connectionpool as connectionpool
 
 
 class UnixHTTPConnection(httplib.HTTPConnection, object):
@@ -28,7 +30,7 @@ def __init__(self, base_url, unix_socket):
 
     def connect(self):
         sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
-        sock.connect(self.base_url.replace("unix:/",""))
+        sock.connect(self.base_url.replace("unix:/", ""))
         self.sock = sock
 
     def _extract_path(self, url):
@@ -40,7 +42,7 @@ def request(self, method, url, **kwargs):
         super(UnixHTTPConnection, self).request(method, url, **kwargs)
 
 
-class UnixHTTPConnectionPool(HTTPConnectionPool):
+class UnixHTTPConnectionPool(connectionpool.HTTPConnectionPool):
     def __init__(self, base_url, socket_path):
         self.socket_path = socket_path
         self.base_url = base_url


Test patch: