问题
I am currently trying to install version 3 of google protocol buffer on windows for python.
I have gone to the python folder through the command line and I am attempting to use:python setup.py build
however I am getting the following error:python : protoc is not installed nor found in ../src. Please compile it or install the binary package.
What's going on here?
回答1:
As the error says, you must first install protoc.exe
. You can get it from the Win32 package included with every Protobuf release. The latest version is here:
https://github.com/google/protobuf/releases/download/v3.0.0-alpha-3/protoc-3.0.0-alpha-3-win32.zip
(You can also build protoc
from source by downloading the C++ source code release.)
回答2:
I was able to solve this issue, by following the steps below:
- Download the package which contains the precompiled version of Protoc from https://github.com/protocolbuffers/protobuf/releases. You will find the zip file at the bottom, in the assets section (e.g.,protoc-3.14.0-win32.zip)
- Add the path of your .exe file which is located inside the bin of the Protoc folder, to the system variables of your system.
- Open cmd and go to the directory where you have cloned the source code for the protocol buffer (https://github.com/protocolbuffers/protobuf). Get inside the python folder
- Check if python version 2.7 or newer is installed by running the command
python -V
. If yes then try the command,python setup.py build
python setup.py install
- check the installed protoc version with
protoc --version
来源:https://stackoverflow.com/questions/31042242/python-protobuf-install-for-windows