1

I tried to install docker-compose using pip but I'm getting this error:

$ docker-compose
  Traceback (most recent call last):
    File "/usr/local/bin/docker-compose", line 7, in <module>
      from compose.cli.main import main
    File "/usr/local/lib/python2.7/dist-packages/compose/cli/main.py", 
      line 17, in <module>
      from . import errors
    File "/usr/local/lib/python2.7/dist-
      packages/compose/cli/errors.py", line 11, in <module>
      from docker.errors import APIError
    File "/usr/local/lib/python2.7/dist-packages/docker/__init__.py", 
      line 2, in <module>
      from .api import APIClient
    File "/usr/local/lib/python2.7/dist-
      packages/docker/api/__init__.py", line 2, in <module>
      from .client import APIClient
    File "/usr/local/lib/python2.7/dist-
      packages/docker/api/client.py", line 11, in <module>
      from .build import BuildApiMixin
    File "/usr/local/lib/python2.7/dist-packages/docker/api/build.py", 
      line 6, in <module>
      from .. import auth
    File "/usr/local/lib/python2.7/dist-packages/docker/auth.py", line 
      6, in <module>
    import dockerpycreds ImportError: No module named dockerpycreds

Update 1: after installing docker_pycreds, as mentioned by an answer, it led me to another error:

Traceback (most recent call last):
  File "/usr/local/bin/docker-compose", line 7, in <module>
    from compose.cli.main import main
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/main.py", 
    line 17, in <module>
    from . import errors
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/errors.py", 
    line 11, in <module>
    from docker.errors import APIError
  File "/usr/local/lib/python2.7/dist-packages/docker/__init__.py", 
    line 2, in <module>
    from .api import APIClient
  File "/usr/local/lib/python2.7/dist-
    packages/docker/api/__init__.py", line 2, in <module>
    from .client import APIClient
  File "/usr/local/lib/python2.7/dist-packages/docker/api/client.py", 
    line 11, in <module>
    from .build import BuildApiMixin
  File "/usr/local/lib/python2.7/dist-packages/docker/api/build.py", 
    line 9, in <module>
    from .. import utils
  File "/usr/local/lib/python2.7/dist-
    packages/docker/utils/__init__.py", line 2, in <module>
    from .build import tar, exclude_paths
  File "/usr/local/lib/python2.7/dist-packages/docker/utils/build.py", 
    line 4, in <module>
    from .utils import create_archive
  File "/usr/local/lib/python2.7/dist-packages/docker/utils/utils.py", 
    line 18, in <module>
    from .. import tls
  File "/usr/local/lib/python2.7/dist-packages/docker/tls.py", line 5,   
    in <module>
    from .transport import SSLAdapter
  File "/usr/local/lib/python2.7/dist-
    packages/docker/transport/__init__.py", line 3, in <module>
    from .ssladapter import SSLAdapter
  File "/usr/local/lib/python2.7/dist-
    packages/docker/transport/ssladapter.py", line 22, in <module>
    urllib3.connection.match_hostname = match_hostname
  AttributeError: 'module' object has no attribute 'connection'

Update 2: after pip install -U urllib3==1.14 as pointed out by another answer, error changed to:

Traceback (most recent call last):
  File "/usr/local/bin/docker-compose", line 7, in <module>
    from compose.cli.main import main
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/main.py", 
    line 17, in <module>
    from . import errors
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/errors.py", 
    line 13, in <module>
    from requests.exceptions import ReadTimeout
  ImportError: cannot import name ReadTimeout
Matheus Lima
  • 2,103
  • 3
  • 31
  • 49

1 Answers1

0

It looks like you need this package installed.

pip install docker_pycreds

http://packages.ubuntu.com/zesty/python-dockerpycreds

https://github.com/shin-/dockerpy-creds/blob/master/dockerpycreds/constants.py

Since you are on a Debian derivative, it will go in your dist-packages. See this post for details on dist/site-packages.

What's the difference between dist-packages and site-packages?

EDIT:

you might need to update dependencies.

pip install urllib3==1.21

or

pip install --upgrade urllib3

and/or

pip install --upgrade pip
Community
  • 1
  • 1
  • After doing that, it led me to another error ```AttributeError: 'module' object has no attribute 'connection'``` – Matheus Lima Apr 28 '17 at 13:48
  • Hum, that worked for me (I tested prior to posting but I am on OSX). I will see if I can find any info about the current state. – David Uselmann Apr 28 '17 at 18:52
  • According to this post I found if you update your urllib3, that might help. "pip install urllib3==1.14" this might not be the latest version so I would look to see what the latest is. This is odd that pip is not automatically updating dependencies. The post: https://github.com/docker/docker-py/issues/1054 – David Uselmann Apr 28 '17 at 18:57
  • What version of pip do you have installed? The reason I found your post is I had a few issues that lead me here and I had to update pip. "pip install --upgrade pip" BTW: you will see many posts with sudo on pip and it is not recommended to do that. If you need sudo then you have installed things incorrectly. – David Uselmann Apr 28 '17 at 19:01