【protobuf】protobuf Mac python3

这次尝试安装3.0.0的protobuf在Mac下。

protobuf在3.0以后的版本的安装和2.x有很多区别,而网上大多数还是2.x的方法,这点需要注意,之前也是踩坑了。。。

先下个3.0的:https://github.com/google/protobuf/releases/tag/v3.0.0

然后解压,在src下面找到readme,就是安装核心protobuf的步骤,可以看到,3.0版本需要以下工具:

To build protobuf from source, the following tools are needed:

  * autoconf
  * automake
  * libtool
  * curl (used to download gmock)
  * make
  * g++
  * unzip

在ubuntu下很好安,在mac下需要注意下,在这个文档里有mac的步骤。

**Note for Mac users**

  For a Mac system, Unix tools are not available by default. You will first need
  to install Xcode from the Mac AppStore and then run the following command from
  a terminal:

    $ sudo xcode-select --install

  To install Unix tools, you can install "port" following the instructions at
  https://www.macports.org . This will reside in /opt/local/bin/port for most
  Mac installations.

    $ sudo /opt/local/bin/port install autoconf automake libtool

  Then follow the Unix instructions above.

先要安装xcode开发者工具,但是目前好像上述方法不行,直接在appstore里下一个xcode即可。然后命令行:


说明有了。

之后需要用port工具安装之前的那一个列表,安port需要在https://guide.macports.org/下一个pkg包,双击即可。在运行

    $ sudo /opt/local/bin/port install autoconf automake libtool
即可。
然后执行:

    $ ./configure
    $ make
    $ make check
    $ sudo make install
    $ sudo ldconfig # refresh shared library cache.
可以在./configure里指定位置,--prefix=path,在再~/.bash_profile里面加环境变量。最后source,具体和另一篇博文一样。这里不说了。

验证:


成功。接下来安装python的支持库。

进入python目录,也有一个readme,打开:大致说了三步骤:

     $ python setup.py build
     $ python setup.py test
     $ python setup.py install

当然还有其他的,但是我没管。第一步卡住了,直接退出运行后两部,成功了。


验证:


成功。

现在我的电脑上安装了两个python和两个protobuf,使用~/.bash_profile切换即可。

之前没有安装3.x成功的原因我觉得是没有把之前用port安装的那一堆软件安上,这也是和protobuf2.x的区别。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值