Ansible安装出现 ImportError/ No module named _text

Posted by Yancy on 2016-06-10

centos6.7 ansible yum安装出现问题:

1
2
3
4
5
ansible --version
Traceback (most recent call last):
File "/usr/bin/ansible", line 46, in <module>
from ansible.module_utils._text import to_text
ImportError: No module named _text

提示这个错误,后面查看官网epel包需要更新,这里我已更新发现还是有问题。

解决方法:
使用pip install安装过ansible就正常使用
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[root@ansible_01 ~]# pip install ansible
Collecting ansible
Downloading ansible-1.9.4.tar.gz (937kB)
100% |████████████████████████████████| 937kB 100kB/s
Collecting paramiko (from ansible)
Downloading paramiko-1.15.3-py2.py3-none-any.whl (166kB)
100% |████████████████████████████████| 167kB 136kB/s
Collecting jinja2 (from ansible)
Downloading Jinja2-2.8-py2.py3-none-any.whl (263kB)
100% |████████████████████████████████| 266kB 1.4MB/s
Collecting PyYAML (from ansible)
Downloading PyYAML-3.11.tar.gz (248kB)
100% |████████████████████████████████| 249kB 72kB/s
Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/local/python27/lib/python2.7/site-packages/setuptools-18.4-py2.7.egg (from ansible)
Collecting pycrypto>=2.6 (from ansible)
Downloading pycrypto-2.6.1.tar.gz (446kB)
100% |████████████████████████████████| 446kB 117kB/s
Collecting ecdsa>=0.11 (from paramiko->ansible)
Downloading ecdsa-0.13-py2.py3-none-any.whl (86kB)
100% |████████████████████████████████| 90kB 141kB/s
Collecting MarkupSafe (from jinja2->ansible)
Downloading MarkupSafe-0.23.tar.gz
Installing collected packages: ecdsa, pycrypto, paramiko, MarkupSafe, jinja2, PyYAML, ansible
Running setup.py install for pycrypto
Running setup.py install for MarkupSafe
Running setup.py install for PyYAML
Running setup.py install for ansible
Successfully installed MarkupSafe-0.23 PyYAML-3.11 ansible-1.9.4 ecdsa-0.13 jinja2-2.8 paramiko-1.15.3 pycrypto-2.6.1

如果提示没有No package 'libffi' found

1
yum install libffi-devel

如果可以正常显示不需要设置 如果还是有问题设置下依赖:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@ansible_01 ~]# find / -name ansible
/etc/ansible
/usr/local/bin/ansible
/usr/local/src/ansible
/usr/local/src/ansible/docsite/js/ansible
/usr/local/src/ansible/bin/ansible
/usr/local/src/ansible/packaging/port/sysutils/ansible
/usr/local/src/ansible/packaging/macports/sysutils/ansible
/usr/local/src/ansible/build/scripts-2.6/ansible
/usr/local/src/ansible/build/lib/ansible
/usr/local/src/ansible/lib/ansible
/usr/local/src/ansible/.git/modules/lib/ansible
/usr/local/lib/python2.7/site-packages/ansible
/usr/lib/python2.6/site-packages/ansible-2.1.0-py2.6.egg/ansible
/usr/lib/python2.6/site-packages/ansible-2.1.0-py2.6.egg/EGG-INFO/scripts/ansible
/home/ansible

然后安装完成正常显示版本信息:

1
2
3
4
5
6
ln -s /usr/local/bin/ansible /usr/bin/ansible
[root@LAN_zabbix pip-9.0.1]# ansible --version
ansible 2.2.1.0
config file =
configured module search path = Default w/o overrides