【已解决】ansible 命令报错 Error -5 while decompressing data: incomplete or truncated stream

一、报错信息: 

执行ansible命令时报错

ERROR! Unexpected Exception, this is probably a bug: Error -5 while decompressing data: incomplete or truncated stream

详细报错如下

[root@localhost tmp]# ansible -h
ERROR! Unexpected Exception, this is probably a bug: Error -5 while decompressing data: incomplete or truncated stream
the full traceback was:

Traceback (most recent call last):
  File "/usr/bin/ansible", line 97, in 
    mycli = getattr(__import__("ansible.cli.%s" % sub, fromlist=[myclass]), myclass)
  File "/usr/lib/python2.7/site-packages/ansible/cli/__init__.py", line 38, in 
    from ansible.inventory.manager import InventoryManager
  File "/usr/lib/python2.7/site-packages/ansible/inventory/manager.py", line 36, in 
    from ansible.plugins.loader import inventory_loader
  File "/usr/lib/python2.7/site-packages/ansible/plugins/loader.py", line 22, in 
    from ansible.parsing.utils.yaml import from_yaml
  File "/usr/lib/python2.7/site-packages/ansible/parsing/utils/yaml.py", line 17, in 
    from ansible.parsing.yaml.loader import AnsibleLoader
  File "/usr/lib/python2.7/site-packages/ansible/parsing/yaml/loader.py", line 30, in 
    from ansible.parsing.yaml.constructor import AnsibleConstructor
  File "/usr/lib/python2.7/site-packages/ansible/parsing/yaml/constructor.py", line 29, in 
    from ansible.parsing.vault import VaultLib
  File "/usr/lib/python2.7/site-packages/ansible/parsing/vault/__init__.py", line 42, in 
    from cryptography.hazmat.backends import default_backend
  File "/usr/lib64/python2.7/site-packages/cryptography/hazmat/backends/__init__.py", line 7, in 
    import pkg_resources
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 70, in 
  File "build/bdist.linux-x86_64/egg/pkg_resources/extern/__init__.py", line 43, in load_module
    __import__(extant)
error: Error -5 while decompressing data: incomplete or truncated stream

二、造成报错的背景

我在ansible-playbook 安装setuptools时,意外终止了,然后再执行ansible命令就报这个错误,

网上搜的方案都未能解决我的问题,对我无用的方法如下:

        1、很多都是说要卸载 cryptography 包 重装ansible

        2、内存不足,要增加内存:我查了服务器内存充足

        ……

尝试多种方法都没有解决。

三、解决方法

重新将setuptools-33.1.1.zip包解压和安装:

cd setuptools-33.1.1  

python setup.py install

执行完毕后再尝试ansible命令正常了。可能有的朋友不是setuptools,也可能是安装到某个包后不能执行,还请朋友们自己尝试。

你可能感兴趣的:(ansible,linux系统,python,ansible)