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

Protobuf TypeError: Descriptors cannot not be created directly. #23

Open
StefanBrand opened this issue Jun 20, 2022 · 2 comments
Open

Comments

@StefanBrand
Copy link

agri_data/tests/imperviousness/test_views.py:5: in <module>
    from vector_tile_base import VectorTile
/usr/local/lib/python3.9/site-packages/vector_tile_base/__init__.py:1: in <module>
    from . import engine
/usr/local/lib/python3.9/site-packages/vector_tile_base/engine.py:3: in <module>
    from . import vector_tile_pb2
/usr/local/lib/python3.9/site-packages/vector_tile_base/vector_tile_pb2.py:33: in <module>
    _descriptor.EnumValueDescriptor(
/usr/local/lib/python3.9/site-packages/google/protobuf/descriptor.py:755: in __new__
    _message.Message._CheckCalledFromGeneratedFile()
E   TypeError: Descriptors cannot not be created directly.
E   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.
E   If you cannot immediately regenerate your protos, some other possible workarounds are:
E    1. Downgrade the protobuf package to 3.20.x or lower.
E    2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
E   
E   More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

The protobuf changelog says the following:

We made some changes in Python language support in Protocol Buffers. Version 4.21.0 is a new major version, following 3.20.1. The new version is based on the upb library, and offers significantly better parsing performance than previous releases, especially for large payloads.
[...]

  • Python upb requires generated code that has been generated from protoc 3.19.0 or newer.
@vincentsarago
Copy link

FYI, if you need to use vector-tile-base you can specify protobuf>=3.0,<4.0 in your dependencies
https://github.com/developmentseed/timvt/blob/master/pyproject.toml#L43

@StefanBrand
Copy link
Author

For services I like to pin to exact versions like protobuf==3.20.1.

Alternatively, here is a PR that updates vector-tile-base: #24

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