简体   繁体   English

Python protobuf 3.20.1 缺少 Any、Empty 和其他类型

[英]Python protobuf 3.20.1 is missing Any, Empty, and other types

I just upgraded protobuf from 3.17.3 to 3.20.1 (macos, python 3.9), and my code started complaining that there is no我刚刚将 protobuf 从 3.17.3 升级到 3.20.1(macos,python 3.9),我的代码开始抱怨没有

from google.protobuf.empty_pb2 import Empty
from google.protobuf.timestamp_pb2 import Timestamp

I checked the package folder under ./venv/lib/python3.9/site-packages/google/protobuf/ and indeed there is no Empty type there.我检查了./venv/lib/python3.9/site-packages/google/protobuf/下的包文件夹,确实那里没有Empty类型。

Ok, I found Timestamp in internal/well_known_types.py .好的,我在internal/well_known_types.py中找到了 Timestamp 。 Why internal?为什么是内部? It does not make sense.它没有任何意义。

Also cannot find StringValue and other wrapper types.也找不到StringValue和其他包装类型。

Is it a known bug, or I'm missing something?这是一个已知的错误,还是我错过了什么? How does someone construct Empty or StringValue objects now?现在有人如何构造EmptyStringValue对象?

OK, I found out my problem.好的,我发现了我的问题。 Everything worked in the first place, but IDE had been complaining about missing types until I installed the types-protobuf package.首先一切正常,但 IDE 一直在抱怨缺少类型,直到我安装了types-protobuf包。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在python文件中使用google.protobuf.Any - Using google.protobuf.Any in python file 如何在 python 变量或任何其他方式中传递空值 - How to pass empty value in python variable or any other way to do 在Windows中将MySQL连接到python时遇到缺少Protobuf的错误 - Getting error of missing protobuf while connecting MySQL to python in windows Python 2.7.10:除了使用len()以外,还有其他方法可以检查输入是否为空 - Python 2.7.10 :Is there any other way to check whether an input is empty other than using len() 如何在Python中设置一个空消息的ProtoBuf字段? - How to set a ProtoBuf field which is an empty message in Python? AttributeError:在使用自定义python插件编译protobuf时缺少六个“indexbytes” - AttributeError : six missing “indexbytes” when compiling protobuf with a custom python plugin 在Python中创建真正为空的类型 - Creating Truly Empty Types in Python 有没有办法在不使用子进程的情况下在 python 中使用 Protobuf 编译器? - Is there any way to use Protobuf compiler in python without using subprocess? Python可以打*(拆包)操作符吗? 或者任何其他可变参数 function 使得所有可变参数类型都在结果类型中? - Can the * (unpacking) operator be typed in Python? Or any other variadic args function such that all variadic types are in the result type? python protobuf为google proto的任何字段分配一个字典 - python protobuf assign a dictionary to any fields of google proto
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM