Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python exception when running example.py #251

Open
surfskidude opened this issue Nov 28, 2022 · 1 comment
Open

Python exception when running example.py #251

surfskidude opened this issue Nov 28, 2022 · 1 comment

Comments

@surfskidude
Copy link

Why do I get the following error when running example.py

$ python3 example.py
Traceback (most recent call last):
File "/mnt/c/tmp/tahu/python/examples/example.py", line 19, in
import sparkplug_b as sparkplug
File "/mnt/c/tmp/tahu/python/examples/../core/sparkplug_b.py", line 13, in
import sparkplug_b_pb2
File "/mnt/c/tmp/tahu/python/examples/../core/sparkplug_b_pb2.py", line 29, in
_PAYLOAD_TEMPLATE_PARAMETER_PARAMETERVALUEEXTENSION = _descriptor.Descriptor(
File "/usr/local/lib/python3.10/dist-packages/google/protobuf/descriptor.py", line 313, in new
_message.Message._CheckCalledFromGeneratedFile()
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).
@tgrusendorf
Copy link
Contributor

Chances are you are getting this because you are running a version of the protobuf package >3.20.x and the sparkplug_b_pb2.py file in this repo hasn't been regenerated with a compatible version of protoc. I regenerated the sparkplug_b_pb2.py file and the error went away for me.

I'm running protobuf version 4.21.9.

If you are using pip, you can check your version by running:
pip show protobuf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants