【问题标题】:How to downgrade protobuf如何降级protobuf
【发布时间】:2023-02-17 13:02:24
【问题描述】:

我偶然在我的 ubuntu vps 上更新了 protobuf。现在一些非常重要的 python 脚本不再起作用了。速度真的不重要。我有两个解决方案:

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).

降级 protobuf 包,不确定这是前进的方向

或设置 PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python - 但我在哪里设置它。在 python 脚本中?

【问题讨论】:

    标签: python protocol-buffers


    【解决方案1】:

    使用 pip 降级 protobuf

    pip install protobuf==3.20.*
    

    注意:上面的*不要按字面意思理解,它被称为“通配符”。您可以根据需要在其中输入您自己的号码,例如 3.20.13.20.5 等。

    这类似于TypeError: Descriptors cannot not be created directly

    【讨论】:

    • 这是弹出的错误no matches found: protobuf==3.20.*
    • 您可以运行“pip install --upgrade pip”来安装和使用新版本的pip。检查这是否有帮助
    【解决方案2】:

    有关背景,请参阅Changes made in May, 2022

    我不鼓励使用 PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python 作为您的解决方案。但是如果你想使用它,你需要在你运行代码的环境中设置这个环境变量(也可能是export它?)

    有关上述更改,请参阅thread

    这是protobufreleases

    如果你不想重新编译你的原型,你可能想尝试移动到3.20.1,但意识到这是该行的结尾并且你正在延迟不可避免的...

    如果你愿意重新编译(和测试)你的原型,你应该考虑转移到4.20.x

    【讨论】:

      猜你喜欢
      • 2019-01-25
      • 2018-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多