How to use python kazoo library?

I am planning on using the Pazon kazoo library for Zookeeper. It's all about Python. The question here is not a zookeeper at all, I think the point is how to use Python kazoo correctly.

I am completely new to python, so I don’t know how to do this and how to use kazoo to connect to zookeeper.

This is a document I read to start using kazoo for Zookeeper.

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

On this wiki they asked to install kazoo. And for this they use the pip command?

What does pip do here? And I'm currently using windows, so I installed cygwin and installed python. 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 I have done this - I copied this command exactly the same as from the above website - pip install kazoo , and ran it on the cygwin command line.

 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... 

Is it installed correctly? Now can I start writing code in python to connect to zookeeper?

Sorry to ask all these dumb questions since I don't have a background with python, so find out a little here.

All about Python, the question here is not a zookeeper at all, I think ..

+6
source share
1 answer

pip is a common way to install packages. It requests and downloads packages from pypi . Casuo was installed according to the operators of the magazine. Give it a try.

You can find the package in where python is installed\lib\site-packages\kazoo .

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

 from kazoo.client import KazooClient 

After starting zookeeper. Your zookeeper configuration will contain client port information.

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

Use this 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() 
+3
source

Source: https://habr.com/ru/post/958339/


All Articles