This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Simple pythonic ZeroConf implementation using system calls

Project Description

A simple Python interface to Zeroconf service discovery and registration.
Supports python >= 2.7 <= 3.5


### Requirements

The `zeroconf` module assumes that the [avahi]( command-line
tools `avahi-browse` and `avahi-publish` are available.
On Ubuntu for example, they may me installed with:

$ sudo apt-get install avahi-tools

The module also depend on [Andrew Moffat's subprocess wrapper][sh]. Install
it with

$ pip install sh

If you install the package using or pip it'll be automatically
handled so you normally don't need to do this.


### Install

Download the source distribution and type:

$ python install

### Running tests

You need py.test installed, just run:

$ py.test --doctest-modules zeroconf/


### Zeroconf Services Discovery

Searching for all available Zeroconf services is done by

>>> from zeroconf import ZeroConf
>>> zc = ZeroConf()
>>> services =

The search can be made more specific, for example:

>>> services =, type="_workstation._tcp", domain="local")

The arguments, all optional, to the `search` functions are:

- `name`: service name, defaults to `None` (interpreted as all),
- `type`: service type, defaults to `None` (interpreted as all),
- `domain`: domain name, defaults to `"local"`.

Search results are dictionaries:

>>> print services
{('tide [f0:7b:cb:42:ff:e0]', '_workstation._tcp', 'local'):
{'txt': '', 'hostname': 'tide.local', 'port': '9', 'address': ''},
('wreck [00:26:18:4c:3f:ee]', '_workstation._tcp', 'local'):
{'txt': '', 'hostname': 'wreck.local', 'port': '9', 'address': ''},
('biohazard [00:18:8b:ac:c8:45]', '_workstation._tcp', 'local'):
{'txt': '', 'hostname': 'biohazard.local', 'port': '9', 'address': ''}}

The keys are `(name, type, domain)` tuples and the values are dictionaries with `txt`,
`hostname`, `port` and `address` keys.

### Zeroconf Services Registration

Register a new zeroconf service in the local domain with:

>>> zc = ZeroConf()
>>> zc.register(name="ghost [08:00:27:bf:49:e1]", type="_workstation._tcp", port="9")

and when you're done, unregister it with:

>>> zc = ZeroConf()
>>> zc.unregister(name="ghost [08:00:27:bf:49:e1]", type="_workstation._tcp", port="9")

All arguments to `unregister` are optional, so we could have done:

>>> zc = ZeroConf()
>>> zc.unregister(name="ghost [08:00:27:bf:49:e1]")

or even, to unregister all services published during the Python session:

>>> zc = ZeroConf()
>>> zc.unregister()


- Sébastien Boisgérault <>:
initial API design, Linux/avahi support.
- Olivier Huynh <>: Windows/dns-sd support.
- David Francos Cuartero <>: OOP rewrite, Python3 support
Release History

Release History

This version
History Node


Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting