Hello, I followed the official tutorial for python,
https://developers.google.com/protocol-buffers/docs/pythontutorial
I run protoc 3.1.0 in my Mac, and in the tutorial, in the section of
> Writing A Message
>
> Now let's try using your protocol buffer classes. The first thing you want
> your address book application to be able to do is write personal details to
> your address book file. To do this, you need to create and populate
> instances of your protocol buffer classes and then write them to an output
> stream.
>
> Here is a program which reads an AddressBook from a file, adds one new
> Person to it based on user input, and writes the new AddressBook back out
> to the file again. The parts which directly call or reference code
> generated by the protocol compiler are highlighted.
>
What i understood here for the red line is that It refers the
addressbook.proto, I use the tutorial code and run it in terminal with this
command:
python test.py addressbook.proto
test.py contains the tutorial code, but i always got the error cause by
this line, address_book.ParseFromString(f.read())
Here is the error:
> Traceback (most recent call last):
>
> File "test.py", line 56, in <module>
>
> address_book.ParseFromString(f.read())
>
> File
>> "/Users/junhao.wen/anaconda2/lib/python2.7/site-packages/protobuf-3.1.0-py2.7.egg/google/protobuf/message.py",
>>
>> line 185, in ParseFromString
>
> self.MergeFromString(serialized)
>
> File
>> "/Users/junhao.wen/anaconda2/lib/python2.7/site-packages/protobuf-3.1.0-py2.7.egg/google/protobuf/internal/python_message.py",
>>
>> line 1087, in MergeFromString
>
> if self._InternalParse(serialized, 0, length) != length:
>
> File
>> "/Users/junhao.wen/anaconda2/lib/python2.7/site-packages/protobuf-3.1.0-py2.7.egg/google/protobuf/internal/python_message.py",
>>
>> line 1113, in InternalParse
>
> new_pos = local_SkipField(buffer, new_pos, end, tag_bytes)
>
> File
>> "/Users/junhao.wen/anaconda2/lib/python2.7/site-packages/protobuf-3.1.0-py2.7.egg/google/protobuf/internal/decoder.py",
>>
>> line 850, in SkipField
>
> return WIRETYPE_TO_SKIPPER[wire_type](buffer, pos, end)
>
> File
>> "/Users/junhao.wen/anaconda2/lib/python2.7/site-packages/protobuf-3.1.0-py2.7.egg/google/protobuf/internal/decoder.py",
>>
>> line 799, in _SkipGroup
>
> new_pos = SkipField(buffer, pos, end, tag_bytes)
>
> File
>> "/Users/junhao.wen/anaconda2/lib/python2.7/site-packages/protobuf-3.1.0-py2.7.egg/google/protobuf/internal/decoder.py",
>>
>> line 850, in SkipField
>
> return WIRETYPE_TO_SKIPPER[wire_type](buffer, pos, end)
>
> File
>> "/Users/junhao.wen/anaconda2/lib/python2.7/site-packages/protobuf-3.1.0-py2.7.egg/google/protobuf/internal/decoder.py",
>>
>> line 820, in _RaiseInvalidWireType
>
> raise _DecodeError('Tag had invalid wire type.')
>
> google.protobuf.message.DecodeError: Tag had invalid wire type.
>
>
>
Can anybody help me????
Thanks in advance
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.