{"id":6441,"library":"python-etcd","title":"python-etcd: etcd v2 Client","description":"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.","status":"abandoned","version":"0.4.5","language":"en","source_language":"en","source_url":"https://github.com/jplana/python-etcd","tags":["etcd","key-value store","distributed systems","client"],"install":[{"cmd":"pip install python-etcd","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Backports concurrent.futures for Python 2 compatibility (only required for Python 2.x)","package":"futures","optional":true},{"reason":"HTTP client library for making requests to etcd","package":"urllib3","optional":false}],"imports":[{"symbol":"Client","correct":"from etcd import Client"}],"quickstart":{"code":"import etcd\nimport os\n\n# Configure etcd host and port (defaults to localhost:2379 for etcd v2)\n# Replace with your etcd v2 cluster address\netcd_host = os.environ.get('ETCD_HOST', '127.0.0.1')\netcd_port = int(os.environ.get('ETCD_PORT', 2379))\n\ntry:\n    # Initialize client for etcd v2\n    client = etcd.Client(host=etcd_host, port=etcd_port)\n    print(f\"Connected to etcd v2 at {etcd_host}:{etcd_port}\")\n\n    # Write a key-value pair\n    client.write('/mykey', 'myvalue')\n    print(\"Wrote '/mykey': 'myvalue'\")\n\n    # Read the value back\n    result = client.read('/mykey')\n    print(f\"Read '/mykey': {result.value}\")\n\n    # Update a key with a TTL (Time To Live)\n    client.write('/tempkey', 'tempvalue', ttl=5)\n    print(\"Wrote '/tempkey' with a 5-second TTL\")\n\n    # Delete a key\n    client.delete('/mykey')\n    print(\"Deleted '/mykey'\")\n\nexcept etcd.EtcdException as e:\n    print(f\"An etcd error occurred: {e}\")\nexcept ConnectionRefusedError:\n    print(f\"Connection to etcd v2 at {etcd_host}:{etcd_port} refused. Is etcd v2 running?\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")","lang":"python","description":"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."},"warnings":[{"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`.","message":"This 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.","severity":"breaking","affected_versions":"All versions"},{"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`.","message":"The 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.","severity":"deprecated","affected_versions":"All versions"},{"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.","message":"Starting 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.","severity":"breaking","affected_versions":">=0.4.1"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z"}