【问题标题】:AttributeError : six missing "indexbytes" when compiling protobuf with a custom python pluginAttributeError:使用自定义 python 插件编译 protobuf 时缺少六个“indexbytes”
【发布时间】:2017-03-08 16:34:47
【问题描述】:

在使用自定义 python 插件编译 protobuf 文件时遇到问题。在一台机器上,它按预期运行,而在另一台机器上,这会导致以下错误:

 Traceback (most recent call last):
      File "C:\...\my_plugin.py", line 14, in <module>
        from google.protobuf.compiler import plugin_pb2 as plugin
      File "C:\Python27\lib\site-packages\google\protobuf\compiler\plugin_pb2.py", line 255, in <module>
        DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\034com.google.protobuf.compilerB\014PluginProtosZ\tplugin_go'))
      File "C:\Python27\lib\site-packages\google\protobuf\descriptor.py", line 869, in _ParseOptions
        message.ParseFromString(string)
      File "C:\Python27\lib\site-packages\google\protobuf\message.py", line 185, in ParseFromString
        self.MergeFromString(serialized)
      File "C:\Python27\lib\site-packages\google\protobuf\internal\python_message.py", line 1062, in MergeFromString
        if self._InternalParse(serialized, 0, length) != length:
      File "C:\Python27\lib\site-packages\google\protobuf\internal\python_message.py", line 1084, in InternalParse
        (tag_bytes, new_pos) = local_ReadTag(buffer, pos)
      File "C:\Python27\lib\site-packages\google\protobuf\internal\decoder.py", line 181, in ReadTag
        while six.indexbytes(buffer, pos) & 0x80:
    AttributeError: 'module' object has no attribute 'indexbytes'
    --my_plugin_out: protoc-gen-my_plugin: Plugin failed with status code

两台机器的 Python 版本相同:2.7.12。

我还确保它们具有相同的 Protobuf 模块版本 (3.2.0) 和六个模块版本 (1.10.0)。

所以我不明白为什么“六”模块会错过上面调用堆栈中提到的“decoder.py”中所需的“indexbytes”方法。

【问题讨论】:

    标签: python python-2.7 protocol-buffers six protoc


    【解决方案1】:

    我无法找到根本原因,但 Python 模块之间似乎存在一些冲突,因为使用 virtualenv 解决了我的问题。 见https://virtualenv.pypa.io/en/stable/userguide/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-02
      • 2021-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-20
      相关资源
      最近更新 更多