How to use Python kazoo library?
Asked Answered
R

1

11

I am planning to use Python kazoo library for Zookeeper. It's all about Python question here not zookeeper at all I guess meaning how to use Python kazoo properly..

I am totally new to python so I have no idea how to get going and how to use kazoo to connect with zookeeper.

This is the document I was reading to start using kazoo for Zookeeper.

http://kazoo.readthedocs.org/en/latest/install.html

In that wiki, they have asked to install kazoo. And they are using some pip command for that?

What does pip do here? And I am currently using windows so I have cygwin installed and python installed as well. I am using Python 2.7.3

host@D-SJC-00542612 ~
$ python
Python 2.7.3 (default, Dec 18 2012, 13:50:09)
[GCC 4.5.3] on cygwin

Now what I did is - I copied this command exactly as it is from the above website - pip install kazoo and ran it on my cygwin command prompt.

host@D-SJC-00542612 ~
$ pip install kazoo
Downloading/unpacking kazoo
  Running setup.py egg_info for package kazoo

    warning: no previously-included files found matching '.gitignore'
    warning: no previously-included files found matching '.travis.yml'
    warning: no previously-included files found matching 'Makefile'
    warning: no previously-included files found matching 'run_failure.py'
    warning: no previously-included files matching '*' found under directory 'sw'
    warning: no previously-included files matching '*pyc' found anywhere in distribution
    warning: no previously-included files matching '*pyo' found anywhere in distribution
Downloading/unpacking zope.interface>=3.8.0 (from kazoo)
  Running setup.py egg_info for package zope.interface

    warning: no previously-included files matching '*.dll' found anywhere in distribution
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    warning: no previously-included files matching '*.pyo' found anywhere in distribution
    warning: no previously-included files matching '*.so' found anywhere in distribution
Requirement already satisfied (use --upgrade to upgrade): distribute in c:\python27\lib\site-packages (from zope.interface>=3.8.0->kazoo)
Installing collected packages: kazoo, zope.interface
  Running setup.py install for kazoo

    warning: no previously-included files found matching '.gitignore'
    warning: no previously-included files found matching '.travis.yml'
    warning: no previously-included files found matching 'Makefile'
    warning: no previously-included files found matching 'run_failure.py'
    warning: no previously-included files matching '*' found under directory 'sw'
    warning: no previously-included files matching '*pyc' found anywhere in distribution
    warning: no previously-included files matching '*pyo' found anywhere in distribution
  Running setup.py install for zope.interface

    warning: no previously-included files matching '*.dll' found anywhere in distribution
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    warning: no previously-included files matching '*.pyo' found anywhere in distribution
    warning: no previously-included files matching '*.so' found anywhere in distribution
    building 'zope.interface._zope_interface_coptimizations' extension
    ********************************************************************************
    WARNING:

            An optional code optimization (C extension) could not be compiled.

            Optimizations for this package will not be available!
    ()
    Unable to find vcvarsall.bat
    ********************************************************************************
    Skipping installation of C:\Python27\Lib\site-packages\zope\__init__.py (namespace package)
    Installing C:\Python27\Lib\site-packages\zope.interface-4.0.5-py2.7-nspkg.pth
Successfully installed kazoo zope.interface
Cleaning up...

Does it got installed properly? Now I can start writing code in python to connect with zookeeper?

Sorry for asking all these dumb questions as I don't have any background with python so learning little bit here..

It's all about Python question here not zookeeper at all I guess..

Rimarimas answered 18/11, 2013 at 21:0 Comment(0)
S
5

pip is common way to install packages. It queries and downloads the packages from pypi. Kazoo has been installed as per the log statements. Give it a try.

you should be able to find the package at where python is installed\lib\site-packages\kazoo.

You should try to load (import) the package without errors:

from kazoo.client import KazooClient

After you have started the zookeeper. Your zookeeper configuration will have the client port details.

tickTime=2000
dataDir=...../zookeeperdata/cluster/server1/data
clientPort=2181
initLimit=5

Use that to connect to zookeeper.

# Create a client and start it
zk = KazooClient(hosts='127.0.0.1:2181')
zk.start()

# Now you can do the regular zookepper API calls
# Ensure some paths are created required by your application
zk.ensure_path("/app/someservice") 

# In the end, stop it
zk.stop()
Sudor answered 6/2, 2014 at 17:12 Comment(1)
is there any possibility that without pip we can install KazooStereophotography

© 2022 - 2024 — McMap. All rights reserved.