zookeeper的python客户端安装

项目中使用了python,需要使用到zookeeper的功能,这里记录一下安装过程。

内核版本:2.6.32

发行版:CentOs-6.6 64bit

1、由于python客户端依赖c的客户端所以要先安装c版本的客户端

[root@rocket c]# cd /usr/local/zookeeper-3.4.6/src/c

[root@rocket c]# ./configure

[root@rocket c]# make

[root@rocket c]# make install

zookeeper的python客户端安装

2、测试c客户端

zookeeper的python客户端安装

看到以上信息说明c版本的客户端已经安装好了,下面安装python版本客户端

3、下载python扩展包,并且解压

[root@rocket local]wget https://pypi.python.org/pypi/zkpython/0.4.2

[root@rocket local]# tar -zxvf zkpython-0.4.2.tar.gz

如果找不到Python.h,可能由于没有安装python-devel

[root@rocket zkpython-0.4.2]# yum -y install python-devel

4、测试是否成功

[root@rocket zookeeper]# cat zk_test.py

import zookeeper

[root@rocket zookeeper]# python zk_test.py

提示找不到libzookeeper_mt.so.2,将libzookeeper_mt.so.2的路径加入到LD_LIBRARY_PATH中

[root@rocket zookeeper]# python zk_test.py

Traceback (most recent call last):

File "zk_test.py", line 1, in <module>

import zookeeper

File "build/bdist.linux-x86_64/egg/zookeeper.py", line 7, in <module>

File "build/bdist.linux-x86_64/egg/zookeeper.py", line 6, in __bootstrap__

ImportError: libzookeeper_mt.so.2: cannot open shared object file: No such file or directory

[root@rocket zookeeper]# export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

再次测试

[root@rocket zookeeper]# python zk_test.py

没报错,说明已经成功安装。

上一篇:处理器(CPU)调度问题


下一篇:快速提升Golang编程能力:那就一起用Go做项目吧