系统 CentOS7

python版本2.7.5

安装 docker-compose 这里就不赘述了

报错信息

[root@VM_0_7_centos bin]# docker-compose -v
Traceback (most recent call last):
  File "/usr/bin/docker-compose", line 5, in <module>
    from compose.cli.main import main
  File "/usr/lib/python2.7/site-packages/compose/cli/main.py", line 23, in <module>
    from ..bundle import get_image_digests
  File "/usr/lib/python2.7/site-packages/compose/bundle.py", line 12, in <module>
    from .config.serialize import denormalize_config
  File "/usr/lib/python2.7/site-packages/compose/config/__init__.py", line 6, in <module>
    from .config import ConfigurationError
  File "/usr/lib/python2.7/site-packages/compose/config/config.py", line 50, in <module>
    from .validation import match_named_volumes
  File "/usr/lib/python2.7/site-packages/compose/config/validation.py", line 12, in <module>
    from jsonschema import Draft4Validator
  File "/usr/lib/python2.7/site-packages/jsonschema/__init__.py", line 33, in <module>
    import importlib_metadata as metadata
  File "/usr/lib/python2.7/site-packages/importlib_metadata/__init__.py", line 9, in <module>
    import zipp
  File "/usr/lib/python2.7/site-packages/zipp.py", line 12, in <module>
    import more_itertools
  File "/usr/lib/python2.7/site-packages/more_itertools/__init__.py", line 1, in <module>
    from .more import *  # noqa
  File "/usr/lib/python2.7/site-packages/more_itertools/more.py", line 460
    yield from iterable
             ^
SyntaxError: invalid syntax

典型的语法错误,python2没有 from 这种语法

我可以确认所需要的more-itertools依赖关系比6.0.0使用Python 2时解决此问题所需的依赖要少python3。LdapCherry 有一个分支,并且我不知道迁移是否会很快进行,或者不知道维护者是否计划维护两个版本。

解决办法

pip install 'more-itertools<=5.0.0'

完事

[root@VM_0_7_centos bin]# pip install 'more-itertools<=5.0.0'
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Looking in indexes: http://mirrors.tencentyun.com/pypi/simple
Collecting more-itertools<=5.0.0
  Downloading http://mirrors.tencentyun.com/pypi/packages/2f/9d/dcfe59e213093695f108508af1214cf9cd95cc5489e46877ec5cb56369e5/more_itertools-5.0.0-py2-none-any.whl (52kB)
     |████████████████████████████████| 61kB 928kB/s 
Requirement already satisfied: six<2.0.0,>=1.0.0 in /root/.local/lib/python2.7/site-packages (from more-itertools<=5.0.0) (1.13.0)
Installing collected packages: more-itertools
  Found existing installation: more-itertools 8.0.2
    Uninstalling more-itertools-8.0.2:
      Successfully uninstalled more-itertools-8.0.2
Successfully installed more-itertools-5.0.0
[root@VM_0_7_centos bin]# docker-compose -v
docker-compose version 1.25.0, build b42d419

 

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐