安装ansible时报的错误:

/pycrypto-2.6.1/egg-dist-tmp-HelzWa
warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
src/MD2.c:31:20: 错误:Python.h:没有那个文件或目录
src/MD2.c:131: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
In file included from src/MD2.c:147:
src/hash_template.c:48: 错误:expected specifier-qualifier-list before ‘PyObject_HEAD’
src/hash_template.c:59: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘PyTypeObject’
src/hash_template.c: 在函数‘newALGobject’中:
src/hash_template.c:69: 警告:隐式声明函数‘PyObject_New’
src/hash_template.c:69: 错误:expected expression before ‘ALGobject’
src/hash_template.c: 在文件层:
src/hash_template.c:76: 错误:expected ‘)’ before ‘*’ token
src/hash_template.c:91: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/hash_template.c:110: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/hash_template.c:122: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/hash_template.c:162: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/hash_template.c:188: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/hash_template.c:190: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ALG_methods’
src/hash_template.c:199: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/hash_template.c:225: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ALGtype’
src/hash_template.c:271: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
src/hash_template.c:304: 错误:数组元素的类型不完全
src/hash_template.c:305: 错误:‘PyCFunction’未声明(不在函数内)
src/hash_template.c:305: 错误:expected ‘}’ before ‘ALG_new’
src/hash_template.c: 在函数‘init_MD2’中:
src/hash_template.c:339: 错误:‘PyObject’未声明(在此函数内第一次使用)
src/hash_template.c:339: 错误:(即使在一个函数内多次出现,每个未声明的标识符在其
src/hash_template.c:339: 错误:所在的函数内也只报告一次。)
src/hash_template.c:339: 错误:‘m’未声明(在此函数内第一次使用)
src/hash_template.c:351: 错误:‘ALGtype’未声明(在此函数内第一次使用)
src/hash_template.c:351: 错误:‘PyType_Type’未声明(在此函数内第一次使用)
src/hash_template.c:352: 警告:隐式声明函数‘Py_InitModule’
src/hash_template.c:356: 错误:‘o’未声明(在此函数内第一次使用)
src/hash_template.c:356: 警告:隐式声明函数‘PyInt_FromLong’
src/hash_template.c:356: 警告:隐式声明函数‘PyDict_SetItemString’
src/hash_template.c:356: 警告:隐式声明函数‘PyModule_GetDict’
src/hash_template.c:356: 警告:隐式声明函数‘Py_DECREF’
src/hash_template.c:360: 警告:隐式声明函数‘PyErr_Occurred’
src/hash_template.c:361: 警告:隐式声明函数‘Py_FatalError’
error: Setup script exited with error: command 'gcc' failed with exit status 1

解决方法:
安装python-dev即可,虽然运行python setup.py install时还有警告,但是已经没有错误了
centos:

yum install python-devel

ubuntu:

apt-get install python-dev