python调用Google Protocol Buffer

本文介绍了如何在Python环境中调用Google Protocol Buffer。通过执行'make', 'make check', 'make install'步骤进行编译检查与安装,接着在Python目录下运行'setup.py install --prefix=$INSTALL_DIR'完成Python环境的集成。" 87381840,8373085,Python初学者:四个基础编程练习,"['Python学习', 'Python零基础', '编程练习']
摘要由CSDN通过智能技术生成
下载地址:
http://code.google.com/p/protobuf/downloads/list

安装命令
tar -xzf protobuf-2.5.0.tar.gz
 cd protobuf-2.5.0
 ./configure --prefix=$INSTALL_DIR

 make 

 make check

 make install

然后进入python目录,

python setup.py install --prefix=$INSTALL_DIR


写proto文件
package lm;
message Person
{
        required int32  id = 1;
        required string str = 2;
        optional int32  opt = 3;
}
保存为 testp.testpb.proto

编译指令
protoc -I=/home/workspace/testprob --python_out=/home/workspace/testprob /home/workspace/testprob/testp.testpb.proto

google
https://developers.google.com/protocol-buffers/docs/pythontutorial

报错
package directory 'google/protobuf/compiler' does not exist

解决
https://
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值