Protobuf: Beginner Coder. Unable to install protoc to Python

Created on 24 Jul 2016  路  8Comments  路  Source: protocolbuffers/protobuf

C:\Users\X\Desktop\protobuf-3.0.0-beta-4\python>"C:\Python27\python.exe" setup.py build
running build
running build_py
Generating google/protobuf/descriptor_pb2.py...
protoc is not installed nor found in ../src. Please compile it or install the binary package.

I found the "\bin\protoc.exe" file but when I click it, it just opens and closes. Do I have to put the bin file in the python directory or somewhere before executing it?

question

Most helpful comment

You need to update the PATH variable:

C:\Users\X\Desktop\protobuf-3.0.0-beta-4\python> set PATH=X:\path\to\bin;%PATH%
C:\Users\X\Desktop\protobuf-3.0.0-beta-4\python> protoc --version
libprotoc 3.0.0

All 8 comments

You need to update the PATH variable:

C:\Users\X\Desktop\protobuf-3.0.0-beta-4\python> set PATH=X:\path\to\bin;%PATH%
C:\Users\X\Desktop\protobuf-3.0.0-beta-4\python> protoc --version
libprotoc 3.0.0

Did you understand this hdubb? I'm still having some trouble.
Attached is an image of my current path variables on win 10.
image

@Henji96 I believe you have already found the solution, but since this is one of the top results returned by Google and it's still not closed I'll take advantage... :)

To make it work you need to download the Windows binary, eg: protoc-3.0.0-win32.zip from: https://developers.google.com/protocol-buffers/docs/downloads
Once unzipped you will find a /bin folder which is the one that needs to be added to your PATH, eg: D:\some_path\protoc-3.0.0-win32\bin

Once added to the PATH, go back to your protobuf and run the python setup.py as usual

And in case you use python>=3.x and you get an error when running the test due to...:

line 639, in testIntegerTypes
    TestGetAndDeserialize('optional_uint32', 1 << 31, long)
NameError: name 'long' is not defined

...you may want to check the following link :) https://github.com/google/protobuf/issues/1504

@ser-dev Thanks for the helpful tips!

pip install protobuf

Reading the code on where setup.py looks for the protoc.exe will make it clear where you can place it.

https://chromium.googlesource.com/external/github.com/google/protobuf/+/HEAD/python/setup.py

for example place the binariy into the protocbuf /src/ or create a OS env var PROTOC

I am having the same problem. I am working on Protobuf 3.8.0 and there is no bin folder. Please can any one help.

To first install protoc on your machine, please check out this guide:

https://docs.google.com/document/d/1XL2LrQuYEAfRBvoOVYdg7rL7D1QvwjAaiJbAbqoJEtk/edit?usp=sharing

After installing protoc as directed in the document above, go ahead and run setup.py

Was this page helpful?
0 / 5 - 0 ratings