centos6 安装protobuf

问题

python 缺失protobuf包
ImportError: No module named google.protobuf.internal

解决办法

  • 安装
    传送门 自己下载所需对应版本
#下载
[root@centos6 develop]# wget https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protobuf-all-3.6.1.tar.gz
#解压
[root@centos6 develop]# tar zxf protobuf-all-3.6.1.tar.gz 
#到解压目录
[root@centos6 develop]# cd protobuf-3.6.1/
# 编译 安装
[root@centos6 protobuf-3.6.1]# ./configure 
[root@centos6 protobuf-3.6.1]# make
[root@centos6 protobuf-3.6.1]# make install

# 安装protobuf的python模块
[root@centos6 protobuf-3.6.1]# cd python/
[root@centos6 python]# python setup.py build
[root@centos6 python]# python setup.py install

ps:如果没有遇到编译上的问题,那么恭喜你了。我就遇到了下述超级多问题

问题

  • 问题1
checking dependency style of gcc... (cached) gcc3
checking how to run the C preprocessor... gcc -E
checking how to run the C++ preprocessor... /lib/cpp
configure: error: in `/develop/protobuf-3.6.1':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details

#问题的根源是缺少必要的C++库,执行下述命令安装对应的库
[root@centos6 protobuf-3.6.1]# yum install glibc-headers
[root@centos6 protobuf-3.6.1]# yum install gcc-c++
  • 问题2
# ./configure 出现问题
configure: error: in `/develop/protobuf-3.6.1':
configure: error: sched_yield was not found on your system

#查看对应的config.log   原因就是你系统的gcc版本过低,不支持c++11 ,需要4.7.1以上

configure:7553: result: use default: -O2  -g -std=c++11 -DNDEBUG
configure:7573: checking whether __SUNPRO_CC is declared
configure:7573: g++ -c  -g -std=c++11 -DNDEBUG  conftest.cpp >&5
cc1plus: error: unrecognized command line option "-std=c++11"

请移步升级GCC文章centos 6.5 手动升级gcc

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容