代码之家  ›  专栏  ›  技术社区  ›  htopiwala

Docker compose脚本抱怨python模块导入

  •  1
  • htopiwala  · 技术社区  · 6 年前

    Docker脚本 docker-compose --version 现在抛出一个奇怪的错误,并抱怨缺少python模块 ordered_dict pip awscli 使用pip。

    下面是我运行时得到的堆栈跟踪

    Traceback (most recent call last):
      File "/usr/bin/docker-compose", line 9, in <module>
        load_entry_point('docker-compose==1.8.0', 'console_scripts', 'docker-compose')()
      File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 484, in load_entry_point
        return get_distribution(dist).load_entry_point(group, name)
      File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2725, in load_entry_point
        return ep.load()
      File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2343, in load
        return self.resolve()
      File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2349, in resolve
        module = __import__(self.module_name, fromlist=['__name__'], level=0)
      File "/usr/lib/python2.7/dist-packages/compose/cli/main.py", line 14, in <module>
        from . import errors
      File "/usr/lib/python2.7/dist-packages/compose/cli/errors.py", line 9, in <module>
        from docker.errors import APIError
      File "/usr/lib/python2.7/dist-packages/docker/__init__.py", line 20, in <module>
        from .client import Client, AutoVersionClient, from_env # flake8: noqa
      File "/usr/lib/python2.7/dist-packages/docker/client.py", line 18, in <module>
        import requests
      File "/usr/lib/python2.7/dist-packages/requests/__init__.py", line 58, in <module>
        from . import utils
      File "/usr/lib/python2.7/dist-packages/requests/utils.py", line 26, in <module>
        from .compat import parse_http_list as _parse_list_header
      File "/usr/lib/python2.7/dist-packages/requests/compat.py", line 42, in <module>
        from .packages.urllib3.packages.ordered_dict import OrderedDict
    ImportError: No module named ordered_dict
    
    2 回复  |  直到 6 年前
        1
  •  27
  •   Chandramouli Rajagopalan    5 年前

    通过在shell中执行以下命令,安装urllib3版本1.22并卸载以前的urllib3 verion

    pip uninstall urllib3
    pip install urllib3==1.22
    
        2
  •  7
  •   htopiwala    6 年前

    重新安装docker compose为我做到了这一点。您可以通过删除 docker-compose 归档自 /usr/local/bin here .

        3
  •  4
  •   meles    3 年前

    您需要重新安装。

    下面是我在Ubuntu 18.04上的一些步骤

    弗斯特 去除 已安装的docker组合二进制文件:

    sudo rm -r /usr/bin/docker-compose
    sudo rm -r /usr/local/bin/docker-compose
    

    安装:

    cd ~/
    
    sudo curl -L "https://github.com/docker/compose/releases/download/1.25.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    
    sudo chmod +x /usr/local/bin/docker-compose
    
    sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
    
    docker-compose --version
    

    您可以在此处阅读更多内容: https://docs.docker.com/compose/install/#install-compose