[英]Error in importing compiled protobuf in gRPC framework with Python
我用 gRPC 編寫了一個服務。 當我啟動該服務時,它無法導入已編譯的 protobuf 並顯示以下錯誤消息:
from google.protobuf import descriptor as _descriptortitus| ModuleNotFoundError: No module named 'google'
試圖重現你的問題。
我的配置一切正常。
看起來pip
有多個google
包。
而一個名為google
實際上並不是 google 的官方包。
您是否使用pip install google
安裝 google 包?
我做了如下
pip install protobuf
pip freeze
protobuf==3.13.0
six==1.15.0
from google.protobuf import descriptor
dir(descriptor)
['Descriptor', 'DescriptorBase', 'DescriptorMetaclass', 'EnumDescriptor', 'EnumValueDescriptor', 'Error', 'FieldDescriptor', 'FileDescriptor', 'MakeDescriptor', 'MethodDescriptor', 'OneofDescriptor', 'ServiceDescriptor', 'TypeTransformationError', '_Deprecated', '_Lock', '_NestedDescriptorBase', '_OptionsOrNone', '_ParseOptions', '_ToCamelCase', '_ToJsonName', '_USE_C_DESCRIPTORS', '__author__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_internal_create_key', '_lock', '_message', 'api_implementation', 'binascii', 'os', 'six', 'threading', 'warnings']
我的python版本是
Python 3.6.7 (default, Dec 5 2018, 15:02:05)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.