安装Protobuf

本文详细介绍如何通过源码方式安装Protobuf,并配置其环境。包括卸载旧版本、安装依赖包、编译安装Protobuf及其Python模块等步骤。此外还提供了安装一系列辅助库的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

源码安装:

1. protobuf下载地址:https://github.com/google/protobuf/releases

2. 卸载掉老版本的Protocol:apt-get remove libprotobuf-dev

3. 先安装依赖:

apt-get install autoconf automake libtool curl make g++ unzip

apt-get install autoconf

apt-get install automake

apt-get install libtool

4. 安装protobuf:

#  tar -xf  protobuf-all-3.6.0.tar.gz

#  cd protobuf-3.5.0

#  ./configure   (若果用:./configure --prefix=/usr/local/protobuf  转6)

#  make

#  make check

#  make install

#  ldconfig

5. 安装protobuf的python模块:

#  cd ./python

#  python setup.py build

#  python setup.py test

#  python setup.py install

6. 配置protobuf:

(1) vim /etc/profile,添加

export PATH=$PATH:/usr/local/protobuf/bin/

export PKG_CONFIG_PATH=/usr/local/protobuf/lib/pkgconfig/

保存执行,source /etc/profile。同时在~/.profile中添加上面两行代码,否则会出现登录用户找不到protoc命令。

(2) 配置动态链接库

vim /etc/ld.so.conf,在文件中添加/usr/local/protobuf/lib(注意: 在新行处添加),然后执行命令: ldconfig

安装完之后,使用protoc --version查看版本.

使用dpkg -L libprotobuf-dev,查找路径,发现在/usr/lib/x86_64-linux-gnu里面还是有libprotobuf.so.8的一系列文件。卸载掉老版本的protocol后,使用sudo rm -rf强制删除了这些文件。

验证python模块有没有被正确安装:

python -c "import google.protobuf;print(google.protobuf.__version__)"  或者

# python    >>>import google.protobuf

 

安装相关库文件:

sudo apt-get install protobuf-compiler python-pil python-lxml python-tk

sudo pip install Cython

sudo pip install pillow

sudo pip install lxml

sudo pip install jupyter

sudo pip install matplotlib

安装一些必要的库文件,譬如:OpenGL (e.g., Mesa), GLU, GLUT, and X11 (including Xi, Xmu, and GLX).  

$ sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev

  1. $ nvcc -V不出意外的话应该会提示,nvcc没有安装,其实就是,nvidia-cuda-toolkit的编译器没有安装完整: $ sudo apt-get install nvidia-cuda-toolkit
  2. apt-get install libatlas-base-dev
  3. sudo apt-get -y install libopencv-dev提示需要依赖项,

改用sudo aptitude install libopencv-dev

因为没有aptitude,先安装 sudo apt-get install aptitude

sudo apt-get -y install x264 v4l-utils ffmpeg

python环境安装:

apt-get install python-numpy python-scipy python-matplotlib python-sklearn python-skimage python-h5py python-leveldb python-networkx python-nose python-pandas python-gflags ipython

python3环境安装:

apt-get install python3-numpy python3-scipy python3-matplotlib python3-sklearn python3-skimage python3-h5py python3-leveldb python3-networkx python3-nose python3-pandas python3-gflags ipython python3-pip

pip install -U protobuf  安装最新版protobuf

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值