如何降级Protobuf

发布于 2025-02-13 22:54:50 字数 709 浏览 0 评论 0原文

偶然,我在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软件包,不确定这是前进的方向

设置protast_buffers_python_implementation = python - 但是我在哪里设置此设置。在Python脚本中?

By accident I updated protobuf on my Ubuntu vps. Now some very essential Python scripts don't work anymore. Speed isn't really important. I got two solutions:

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

Downgrade the protobuf package, not sure it that's the way forward

or Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python - but where do I set this. In the python script?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

罪#恶を代价 2025-02-20 22:54:50

使用PIP降级Protobuf

pip install protobuf==3.20.*

注意:上面的*从字面上进行,它称为“通配符”。 根据需要将自己的号码放在其中,例如3.20.13.20.5等。

您可以 .com/esporate/72441758/typeError-descriptors-cannot-not-be-be-be-be-be-be-be-typeErlor:typeError:无法直接创建描述符

Downgrade protobuf using pip

pip install protobuf==3.20.*

Note: the * above is not to be taken literally, it's called a "wildcard". You put your own number in there as needed, as in 3.20.1, 3.20.5, etc.

This is similar to TypeError: Descriptors cannot not be created directly

说不完的你爱 2025-02-20 22:54:50

参见 2022年5月进行的更改用于背景。

我会使用stolopt_buffers_python_implementation = python作为解决方案而劝阻。但是,如果要使用它,则需要在运行使用生成源的代码(客户端和服务器)中设置此环境变量(以及可能gode> grom> grom它?)如果适用)。

请参阅此 thread 关于上述更改。

这是protobuf 发行

如果您不想重新编译原始人,则可能需要尝试移动到3.20.1,但要意识到这是行的终结,您将延迟不可避免的...

如果您'愿意重新编译(和测试)您的触发器,您应该考虑移至4.20.x

See Changes made in May, 2022 for background.

I'd discourage using PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python as your solution. But if you want to use it, you would need to set this environment variable (and possibly export it too?) in the environment where you're running code that uses the generated sources (both client and server if applicable).

See this thread about the above change.

Here's the protobuf releases.

If you don't want to recompile your protos, you may want to try moving to 3.20.1 but realize this is the end of the line and you're delaying the inevitable...

If you're willing to recompile (and test) your protos, you should consider moving to 4.20.x.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文