kragniz / kragniz/python-etcd3
pip install etcd3 does not work because of an incompatible protobuf version
- Dominant language
- Python
- Stars
- 450
- Forks
- 194
- PR merge metrics
- No merged PRs in 30d
Description
I spent a few hours trying multiple python etcd3 clients, and all failed because of protobuf. The steps were:
1. Run `pip install etcd3`.
2. Open the python interpreter.
3. Type `import etcd3`.
4. Got an error related to protobuf.
```
Python 3.12.3 (main, Nov 6 2024, 18:32:19) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import etcd3
Traceback (most recent call last):
File "", line 1, in
File "/tmp/venv/lib/python3.12/site-packages/etcd3/__init__.py", line 3, in
import etcd3.etcdrpc as etcdrpc
File "/tmp/venv/lib/python3.12/site-packages/etcd3/etcdrpc/__init__.py", line 1, in
from .rpc_pb2 import *
File "/tmp/venv/lib/python3.12/site-packages/etcd3/etcdrpc/rpc_pb2.py", line 16, in
from etcd3.etcdrpc import kv_pb2 as kv__pb2
File "/tmp/venv/lib/python3.12/site-packages/etcd3/etcdrpc/kv_pb2.py", line 33, in
_descriptor.EnumValueDescriptor(
File "/tmp/venv/lib/python3.12/site-packages/google/protobuf/descriptor.py", line 920, in __new__
_message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
```
The solution is, either modify the `requirements.txt` to force using protobuf v3, or install the library directly from the sources:
```
pip install git+https://github.com/kragniz/python-etcd3.git@e58a899579ba416449c4e225b61f039457c8072a
```
Please, I suggest pushing the latest GitHub version to Pypi. If not, other people is going to get the same error.
Contributor guide
Research direction
Start by reproducing the Python 3.12 installation and import steps in a clean environment. Inspect requirements.txt and compare the published package with commit e58a899579ba416449c4e225b61f039457c8072a. Done means a fresh pip install of etcd3 can import successfully without the reported protobuf descriptor error, with the relevant package or dependency metadata updated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100