解决centos7 docker-compose Traceback

问题:

docker-compose 运行报错

eg:
Traceback (most recent call last):
  File "/usr/bin/docker-compose", line 7, in
    from compose.cli.main import main
  File "/usr/lib/python2.7/site-packages/compose/cli/main.py", line 17, in
    import docker
  File "/usr/lib/python2.7/site-packages/docker/__init__.py", line 2, in
    from .api import APIClient
  File "/usr/lib/python2.7/site-packages/docker/api/__init__.py", line 2, in
    from .client import APIClient
  File "/usr/lib/python2.7/site-packages/docker/api/client.py", line 5, in
    import requests
  File "/usr/lib/python2.7/site-packages/requests/__init__.py", line 58, in
    from . import utils
  File "/usr/lib/python2.7/site-packages/requests/utils.py", line 32, in
    from .exceptions import InvalidURL
  File "/usr/lib/python2.7/site-packages/requests/exceptions.py", line 10, in
    from .packages.urllib3.exceptions import HTTPError as BaseHTTPError
  File "/usr/lib/python2.7/site-packages/requests/packages/__init__.py", line 95, in load_module
    raise ImportError("No module named '%s'" % (name,))
ImportError: No module named 'requests.packages.urllib3'


思路: 


0x01. 依据 ImportError: No module named 'requests.packages.urllib3' //发现缺少模块


0x02. pip uninstall requests //卸载掉这个模块


0x03. pip install requests //重新安装模块


0x04. 
      Requirement already satisfied: requests in /usr/lib/python2.7/site-packages (2.6.0)
      docker-compose 1.21.2 has requirement requests!=2.11.0,!=2.12.2,!=2.18.0,<2.19,>=2.6.1, but you'll have requests 2.6.0 which is incompatible.
      docker 3.3.0 has requirement requests!=2.18.0,>=2.14.2, but you'll have requests 2.6.0 which is incompatible.
      //提示docker-compose docker 与 requests 模块冲突


0x05. pip uninstall docker-compose //卸载掉docker-compose
      
0x06. pip install requests //再次尝试安装requests 模块
      Requirement already satisfied: requests in /usr/lib/python2.7/site-packages (2.6.0)
      docker 3.3.0 has requirement requests!=2.18.0,>=2.14.2, but you'll have requests 2.6.0 which is incompatible.
      //依旧冲突


0x07. pip install docker//重新安装docker测试问题
      Found existing installation: requests 2.6.0
      Cannot uninstall 'requests'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.


0x08. pip install docker-compose//重新安装docker-compose 依旧出问题
      Found existing installation: requests 2.6.0
      Cannot uninstall 'requests'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.


0x09. pip install --ignore-installed requests  //忽略 错误 安装模块


0x10. docker-compose -v //查看版本 观察问题是否解决
      docker-compose version 1.21.2, build a133471 


#整个过程提供了一种接解决问题的思路依据报错逐步排查,找出最终问题,然后通过参考文献解决问题,大家一起成长吧.


参考文献:https://github.com/blockstack/blockstack-core/issues/504
          https://blog.csdn.net/xiaoxianerqq/article/details/80579113
          https://blog.csdn.net/u014242496/article/details/73834278

你可能感兴趣的:(docker)