简述:在centOS6.5上使用pip安装ansible(version=2.1.1.0)时报错

报错解决

  • 解决如下 分析为PyCrypto模块安装有问题,所以就直接卸载重装。。有能力的话我会进一步探究这个报错,不过现在以下方法可以解决,先这样吧
1
2
3
pip uninstall python-keyczar pycrypto pyasn1
yum erase python-keyczar python-crypto pyasn1
yum install python-keyczar
  • 报错如下

ERROR! Unexpected Exception: ‘module’ object has no attribute ‘HAVE_DECL_MPZ_POWM_SEC’ the full traceback was: Traceback (most recent call last): File “/usr/bin/ansible”, line 81, in from ansible.cli.adhoc import AdHocCLI as mycli File “/usr/lib/python2.6/site-packages/ansible/cli/adhoc.py”, line 28, in from ansible.executor.task_queue_manager import TaskQueueManager File “/usr/lib/python2.6/site-packages/ansible/executor/task_queue_manager.py”, line 29, in from ansible.executor.process.result import ResultProcess File “/usr/lib/python2.6/site-packages/ansible/executor/process/result.py”, line 34, in from Crypto.Random import atfork File “/usr/lib64/python2.6/site-packages/Crypto/Random/init.py”, line 29, in from Crypto.Random import _UserFriendlyRNG File “/usr/lib64/python2.6/site-packages/Crypto/Random/_UserFriendlyRNG.py”, line 38, in from Crypto.Random.Fortuna import FortunaAccumulator File “/usr/lib64/python2.6/site-packages/Crypto/Random/Fortuna/FortunaAccumulator.py”, line 39, in import FortunaGenerator File “/usr/lib64/python2.6/site-packages/Crypto/Random/Fortuna/FortunaGenerator.py”, line 34, in from Crypto.Util.number import ceil_shift, exact_log2, exact_div File “/usr/lib64/python2.6/site-packages/Crypto/Util/number.py”, line 56, in if _fastmath is not None and not _fastmath.HAVE_DECL_MPZ_POWM_SEC: AttributeError: ‘module’ object has no attribute ‘HAVE_DECL_MPZ_POWM_SEC’

安装过程

  • 命令脚本片段(摘自sam的脚本)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#安装PIP
yum install python-pip.noarch python-devel libxslt-devel libffi-devel openssl-devel python-devel gcc-c++ gcc PyYAML python-babel python-crypto  python-httplib2 python-jinja2 python-keyczar python-markupsafe python-paramiko python-pyasn1 python-simplejson python-six -y
mkdir ~/.pip/
echo "
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com" >> ~/.pip/pip.conf
#安装ansible
pip install --upgrade pip python-keyczar
pip install ansible==2.1.1.0