用于Windows的python protobuf安装

时间:2015-06-25 05:54:30

标签: python-2.7 protocol-buffers

我目前正在尝试在Windows上为python安装google协议缓冲区的第3版。

我通过命令行转到python文件夹,我试图使用:
python setup.py build

然而我收到以下错误:
python : protoc is not installed nor found in ../src. Please compile it or install the binary package.

这里发生了什么?

2 个答案:

答案 0 :(得分:2)

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.)

答案 1 :(得分:0)

我能够通过以下步骤解决此问题:

  1. https://github.com/protocolbuffers/protobuf/releases 下载包含 Protoc 预编译版本的包。您将在底部的资产部分找到 zip 文件(例如,protoc-3.14.0-win32.zip)
  2. 将位于 Protoc 文件夹的 bin 内的 .exe 文件的路径添加到系统的系统变量中。
  3. 打开 cmd 并转到您为协议缓冲区 (https://github.com/protocolbuffers/protobuf) 克隆源代码的目录。进入python文件夹
  4. 通过运行命令 python -V 检查是否安装了 Python 2.7 或更高版本。如果是,则尝试该命令,python setup.py build
  5. python setup.py install
  6. 使用 protoc --version 检查安装的 protoc 版本