Docker脚本docker-compose --version
现在抛出一个奇怪的错误,并抱怨缺少python模块ordered_dict
。不知道为什么会这样,但是以前它工作得很好。不知道它是否相关,但是我为python安装了pip
,后来又使用pip安装了awscli
。
下面是我在运行docker-compose --version
时获得的堆栈跟踪信息
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
答案 0 :(得分:2)
重新安装docker-compose对我有用。您可以通过从docker-compose
删除/usr/local/bin
文件并按照here提供的说明重新安装来重新安装。
答案 1 :(得分:1)
通过安装urllib3 1.22版来执行此操作,并通过在外壳中执行以下命令来卸载以前的urllib3版本
pip uninstall urllib3
pip install urllib3==1.22
答案 2 :(得分:1)
您需要重新安装。
以下是在Ubuntu 18.04上对我有用的步骤
重新安装步骤:
首先删除已安装的docker-combines二进制文件:
/usr/bin$ sudo rm -r docker-compose
/usr/local/bin$ sudo rm -r 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