Registry / database / python-etcd

python-etcd

JSON →
library0.4.5pypypi✓ verified 87d ago

A Python client library for etcd. This library specifically targets and supports the etcd v2 API. The last release (0.4.5) was in March 2017, and it is no longer actively maintained. It has no stated release cadence.

pip install python-etcd
INSTALL
IMPORT
SIG · PYTHON-ETCD
P
python-etcd
databasepythonv0.4.5
Install
2.8s avg
Import
328ms
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.338s · 23MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.8s · import 0.317s · 24MB
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Client
from etcd import Client

This quickstart demonstrates how to initialize the etcd client, write a key-value pair, read it back, set a TTL, and delete a key. It assumes an etcd v2 server is running and accessible at the specified host and port. Remember this client is ONLY compatible with etcd v2.

import etcd import os # Configure etcd host and port (defaults to localhost:2379 for etcd v2) # Replace with your etcd v2 cluster address etcd_host = os.environ.get('ETCD_HOST', '127.0.0.1') etcd_port = int(os.environ.get('ETCD_PORT', 2379)) try: # Initialize client for etcd v2 client = etcd.Client(host=etcd_host, port=etcd_port) print(f"Connected to etcd v2 at {etcd_host}:{etcd_port}") # Write a key-value pair client.write('/mykey', 'myvalue') print("Wrote '/mykey': 'myvalue'") # Read the value back result = client.read('/mykey') print(f"Read '/mykey': {result.value}") # Update a key with a TTL (Time To Live) client.write('/tempkey', 'tempvalue', ttl=5) print("Wrote '/tempkey' with a 5-second TTL") # Delete a key client.delete('/mykey') print("Deleted '/mykey'") except etcd.EtcdException as e: print(f"An etcd error occurred: {e}") except ConnectionRefusedError: print(f"Connection to etcd v2 at {etcd_host}:{etcd_port} refused. Is etcd v2 running?") except Exception as e: print(f"An unexpected error occurred: {e}")
Debug
Known issues
breakingThis library is strictly designed for and only supports the etcd v2 API. It will NOT work with etcd v3 or later versions, which are the current standard for etcd clusters. Attempts to connect to an etcd v3 cluster will result in connection errors or unexpected behavior.
fix
For etcd v3+ clusters, use a dedicated etcd v3 client library like `python-etcd3` (or `etcd3-py` for more active maintenance) instead of `python-etcd`.
affects: All versions
deprecatedThe library is unmaintained since 2017 (last release 0.4.5). This means it is unlikely to receive updates for new Python versions, bug fixes, or security patches. Using it with modern Python environments (e.g., Python 3.8+) may lead to compatibility issues.
fix
If working with etcd v2 is unavoidable, use with older Python environments (e.g., Python 3.3-3.7). For new projects, migrate to etcd v3 and use an appropriate client like `python-etcd3` or `etcd3-py`.
affects: All versions
breakingStarting from version 0.4.1, explicit support for etcd-backed locking and leader election features was removed from this library. If your application relies on these specific features, using versions 0.4.1 and above will break existing code.
fix
If you need locking/election with this client, you must use version <0.4.1 (e.g., 0.3.x). However, given the overall deprecation of etcd v2 and this library, it is strongly recommended to migrate to etcd v3 and use its built-in concurrency primitives or a dedicated library for v3.
affects: >=0.4.1
Upgrade
Version history
0.4.5latest on PyPI · released Mar 2, 2017
Audit
Dependencies
futuresoptionalBackports concurrent.futures for Python 2 compatibility (only required for Python 2.x)
urllib3requiredHTTP client library for making requests to etcd
Agent activity
16 hits · last 30 days
node
13
OpenAI (training)
1
Resources
python-etcd — pip install python-etcd · libregistry