1

我尝试使用安装docker-composepip但出现此错误:

$ 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

更新 1:安装 docker_pycreds 后,如答案所述,它导致我出现另一个错误:

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'

更新2:在pip install -U urllib3==1.14另一个答案指出之后,错误变为:

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
4

1 回答 1

0

看起来你需要安装这个包。

pip install docker_pycreds

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

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

由于您使用的是 Debian 衍生产品,因此它将包含在您的 dist-packages 中。有关 dist/site-packages 的详细信息,请参阅这篇文章。

dist-packages 和 site-packages 有什么区别?

编辑:

您可能需要更新依赖项。

pip install urllib3==1.21

或者

pip install --upgrade urllib3

和/或

pip install --upgrade pip
于 2017-04-28T13:38:59.357 回答