- 下载zookeeper,去官网下载
zookeeper-3.4.9.tar.gz
- 安装源码(需要装源码,因为zkpython装的时候有头文件引用)
tar xf zookeeper-3.4.9.tar.gz
cd zookeeper-3.4.9/src/c
./configure
make
make install
这样之后,在/usr/local/include/zookeeper
下会安装好zookeeper的源码
3. 安装zkpython
去python包网站https://pypi.Python.org
下载zkpython-0.4.tar.gz
tar xf zkpython-0.4.tar.gz
cd zkpython-0.4
在安装前,需要修改安装依赖的位置,修改setup.py
文件:
在文件中增加zookeeper源码安装到的位置/usr/local/include/zookeeper
include_dirs=["/usr/include/c-client-src", "/usr/local/include/c-client-src", "/usr/local/include/zookeeper"],
执行安装:
python setup.py install
4. 更新python库环境变量
在/usr/local/lib/
发现安装好的库,如下:
[root@lin zkpython-0.4]# ll /usr/local/lib/
total 2556
-rw-r--r--. 1 root root 881364 Dec 22 00:20 libzookeeper_mt.a
-rwxr-xr-x. 1 root root 1011 Dec 22 00:20 libzookeeper_mt.la
lrwxrwxrwx. 1 root root 24 Dec 22 00:20 libzookeeper_mt.so -> libzookeeper_mt.so.2.0.0
lrwxrwxrwx. 1 root root 24 Dec 22 00:20 libzookeeper_mt.so.2 -> libzookeeper_mt.so.2.0.0
-rwxr-xr-x. 1 root root 453559 Dec 22 00:20 libzookeeper_mt.so.2.0.0
-rw-r--r--. 1 root root 833886 Dec 22 00:20 libzookeeper_st.a
-rwxr-xr-x. 1 root root 1001 Dec 22 00:20 libzookeeper_st.la
lrwxrwxrwx. 1 root root 24 Dec 22 00:20 libzookeeper_st.so -> libzookeeper_st.so.2.0.0
lrwxrwxrwx. 1 root root 24 Dec 22 00:20 libzookeeper_st.so.2 -> libzookeeper_st.so.2.0.0
-rwxr-xr-x. 1 root root 433484 Dec 22 00:20 libzookeeper_st.so.2.0.0
更新用户环境变量:
vi ~/.bashrc
增加:
export LD_LIBRARY_PATH=/usr/local/lib/
然后重新加载环境变量
source ~/.bashrc
5. 测试
[root@lin zkpython-0.4]# python
Python 2.7.5 (default, Nov 20 2015, 02:00:19)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import zookeeper
>>>