Reputation: 36028
I am trying to use google protocol buffer in windows with python binding, however I meet some problem during the install step.
Follow the instruction, I have to compile the PB myself using vs, but I have no vs installed on my machine, then I found a window binary at the download page.
Also I download the full source code package, then I put the protoc-2.5.0-win32.zip\protoc.exe
to C:\windows\system32
.
Then I go to the protobuf-2.5.0.zip\python
and run the python setup.py install
to install the python binding.
However I get the error like this:
And when I check the directory, the file google\protobuf\compiler
does not exist.
What's the problem?
Is it possible to use it without compiling?
Upvotes: 3
Views: 1426
Reputation: 697
C:\Users\dev3\protobufcode\protobuf-master\python
$ python setup.py build
$ python setup.py install
C:\Users\dev3\protobufcode
$ python --version
Python 3.6.5
$ python -i build\gen\addressbook_pb2.py
>>> import addressbook_pb2
>>> Person = addressbook_pb2.Person()
>>> person = addressbook_pb2.Person()
>>> person.id = 1234
>>> person.name = "Go Fish"
>>> person.email = "[email protected]"
>>> phone = person.phones.add()
>>> phone.number = "111-2222"
>>> phone.type = addressbook_pb2.Person.HOME
>>> person
name: "Go Fish"
id: 1234
email: "[email protected]"
phones {
number: "111-2222"
type: HOME
}
>>>
Upvotes: 0
Reputation: 84
Before this package can be installed on windows you need to download the compiler (protoc.exe) and put it in the environment execution path.
After this step is done you can run:
python setup.py build
python setup.py install
~yy
Upvotes: 2
Reputation: 8128
I was just suffering from the same problem. The solution is to explicitly do the build step before.
python setup.py build
python setup.py install
That worked for me.
Upvotes: 2