在我们使用python操作zookeeper时,需要安装第三方的工具zkpython。
因为环境的不同,安装过程中可能会报错:致命错误:Python.h:没有那个文件或目录 #include <Python.h>
安装方式可以选择pip安装或源码安装两种方式。
安装过程中需要去zookeeper中的src目录下的c目录中编译、make、make install,具体步骤参考文末链接。
错误代码
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-qv1Ljk/zkpython/setup.py'"'"'; __file__='"'"'/tmp/pip-install-qv1Ljk/zkpython/setup.py'"'"'; f=getattr(tokenize, '"'"'open'"'"', open)(__file__); code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"'); f.close(); exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-NGmTxQ/install-record.txt --single-version-
... ...(这是一堆没用的信息)
zookeeper.c:19:20: 致命错误:Python.h:没有那个文件或目录
#include <Python.h>
编译中断。
error: command 'gcc' failed with exit status 1
错误原因
zookeeper.c:19:20: 致命错误:Python.h:没有那个文件或目录
众所周知,.h的文件是属于c或者java类的头文件,也就是说当前环境缺少python.h的头文件
从而导致编译中断
验证想法,查看是否安装python-devel:rpm -qa | grep python-devel
没有返回结果,想法正确。
解决方法
安装python头文件:yum -y install python-devel
安装zkpython:pip install zkpython
文章评论