I am trying to write a simple program using protobuf in python on MAC. But I am getting "no module named 'google'" error. I installed protobuf using 'brew install protobuf'.
Below are the files.
addressbook.proto:
syntax = "proto3";
package tutorial;
message Person {
optional string name = 1;
optional int32 id = 2;
optional string email = 3;
enum PhoneType {
MOBILE = 0;
HOME = 1;
WORK = 2;
}
message PhoneNumber {
optional string number = 1;
optional PhoneType type = 2;
}
repeated PhoneNumber phones = 4;
}
message AddressBook {
repeated Person people = 1;
}
I used protoc command as below to generate addressbook_pb2.py
protoc -I=. --python_out=. ./addressbook.proto --experimental_allow_proto3_optional
test.py:
import addressbook_pb2
import sys
def writeData():
return
if __name__ == "__main__":
writeData()
I am getting below error.
Traceback (most recent call last):
File "/Users/ka/Desktop/proto_python/test.py", line 1, in <module>
import addressbook_pb2
File "/Users/ka/Desktop/proto_python/addressbook_pb2.py", line 5, in <module>
from google.protobuf import descriptor as _descriptor
ModuleNotFoundError: No module named 'google'
Can some one please help me how to resolve this issue.