kragniz / kragniz/python-etcd3

Can't use etcd3 package?

Open
#2,000 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
450
Forks
194
PR merge metrics
No merged PRs in 30d

Description

I have installed etcd3:

```
etcd3==0.12.0
- grpcio [required: >=1.27.1, installed: 1.49.1]
- six [required: >=1.5.2, installed: 1.16.0]
- protobuf [required: >=3.6.1, installed: 4.21.7]
- six [required: >=1.12.0, installed: 1.16.0]
- tenacity [required: >=6.1.0, installed: 8.1.0]
```

trying to import:

`import etcd3`

Getting the following error:

```
TypeError Traceback (most recent call last)
Cell In [7], line 1
----> 1 import etcd3

File ~/.local/share/virtualenvs/actionstore-workflow-fuzzy-slot-filling-BxsXSO6K/lib/python3.8/site-packages/etcd3/__init__.py:3
1 from __future__ import absolute_import
----> 3 import etcd3.etcdrpc as etcdrpc
4 from etcd3.client import Etcd3Client
5 from etcd3.client import Transactions

File ~/.local/share/virtualenvs/actionstore-workflow-fuzzy-slot-filling-BxsXSO6K/lib/python3.8/site-packages/etcd3/etcdrpc/__init__.py:1
----> 1 from .rpc_pb2 import *
2 from .rpc_pb2_grpc import *

File ~/.local/share/virtualenvs/actionstore-workflow-fuzzy-slot-filling-BxsXSO6K/lib/python3.8/site-packages/etcd3/etcdrpc/rpc_pb2.py:16
11 # @@protoc_insertion_point(imports)
13 _sym_db = _symbol_database.Default()
---> 16 from etcd3.etcdrpc import kv_pb2 as kv__pb2
17 from etcd3.etcdrpc import auth_pb2 as auth__pb2
20 DESCRIPTOR = _descriptor.FileDescriptor(
21 name='rpc.proto',
22 package='etcdserverpb',
(...)
26 ,
27 dependencies=[kv__pb2.DESCRIPTOR,auth__pb2.DESCRIPTOR,])

File ~/.local/share/virtualenvs/actionstore-workflow-fuzzy-slot-filling-BxsXSO6K/lib/python3.8/site-packages/etcd3/etcdrpc/kv_pb2.py:33
12 _sym_db = _symbol_database.Default()
17 DESCRIPTOR = _descriptor.FileDescriptor(
18 name='kv.proto',
19 package='mvccpb',
(...)
22 serialized_pb=_b('\n\x08kv.proto\x12\x06mvccpb\"u\n\x08KeyValue\x12\x0b\n\x03key\x18\x01 \x01(\x0c\x12\x17\n\x0f\x63reate_revision\x18\x02 \x01(\x03\x12\x14\n\x0cmod_revision\x18\x03 \x01(\x03\x12\x0f\n\x07version\x18\x04 \x01(\x03\x12\r\n\x05value\x18\x05 \x01(\x0c\x12\r\n\x05lease\x18\x06 \x01(\x03\"\x91\x01\n\x05\x45vent\x12%\n\x04type\x18\x01 \x01(\x0e\x32\x17.mvccpb.Event.EventType\x12\x1c\n\x02kv\x18\x02 \x01(\x0b\x32\x10.mvccpb.KeyValue\x12!\n\x07prev_kv\x18\x03 \x01(\x0b\x32\x10.mvccpb.KeyValue\" \n\tEventType\x12\x07\n\x03PUT\x10\x00\x12\n\n\x06\x44\x45LETE\x10\x01\x42\x18\n\x14\x63om.coreos.jetcd.apiP\x01\x62\x06proto3')
23 )
27 _EVENT_EVENTTYPE = _descriptor.EnumDescriptor(
28 name='EventType',
29 full_name='mvccpb.Event.EventType',
30 filename=None,
31 file=DESCRIPTOR,
32 values=[
---> 33 _descriptor.EnumValueDescriptor(
34 name='PUT', index=0, number=0,
35 serialized_options=None,
36 type=None),
37 _descriptor.EnumValueDescriptor(
38 name='DELETE', index=1, number=1,
39 serialized_options=None,
40 type=None),
41 ],
42 containing_type=None,
43 serialized_options=None,
44 serialized_start=253,
45 serialized_end=285,
46 )
47 _sym_db.RegisterEnumDescriptor(_EVENT_EVENTTYPE)
50 _KEYVALUE = _descriptor.Descriptor(
51 name='KeyValue',
52 full_name='mvccpb.KeyValue',
(...)
112 serialized_end=137,
113 )

File ~/.local/share/virtualenvs/actionstore-workflow-fuzzy-slot-filling-BxsXSO6K/lib/python3.8/site-packages/google/protobuf/descriptor.py:755, in EnumValueDescriptor.__new__(cls, name, index, number, type, options, serialized_options, create_key)
752 def __new__(cls, name, index, number,
753 type=None, # pylint: disable=redefined-builtin
754 options=None, serialized_options=None, create_key=None):
--> 755 _message.Message._CheckCalledFromGeneratedFile()
756 # There is no way we can build a complete EnumValueDescriptor with the
757 # given parameters (the name of the Enum is not known, for example).
758 # Fortunately generated files just pass it to the EnumDescriptor()
759 # constructor, which will ignore it, so returning None is good enough.
760 return None

TypeError: Descriptors cannot not 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
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the import failure with the listed Python package versions, then inspect etcd3/etcdrpc/rpc_pb2.py and kv_pb2.py, especially their generated descriptor code. Compare the generated files with the installed protobuf version and check the package's dependency metadata. Done means importing etcd3 succeeds under a supported dependency combination.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
databases, distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.