caffe:cannot import name symbol_database/ protobuf problem in caffe

reference:http://blog.163.com/pz124578@126/blog/static/2352269420154852818284/

 1.在跑caffe官网上notebook examples的时候出现: cannot import name symbol_database,这是与protobuf相关的文件,应该是protobuf中缺少symbol_database.py这个文件,那就去github上下载吧,


  from caffe.proto import caffe_pb2
  File "/home/wenyangming/caffe_new/caffe/python/caffe/proto/caffe_pb2.py", line 10, in
    from google.protobuf import symbol_database as _symbol_database


在prtobuf/python/google/protobuf中找到symbol_database.py文件拷贝到你的protobuf,

我的protobuf地址是 /usr/lib/python2.7/dist-packages/google/protobuf


2.No module named google.protobuf.internal

这说明你没有添加google.protobuf.的位置

sys.path.append('/usr/lib/python2.7/dist-packages/')

3.添加了还是出错can’t import symbol_database 等类似错误TypeError: __init__() got an unexpected keyword argument ‘oneofs’ 等错错误

这些错误是google.protobuf 版本问题所导致的。

解决办法:下载protobuf-2.6.0

切换到/usr/lib/python2.7/dist-packages/ 目录下  先将google 文件夹备份

sudo mv google google_back

将其protobuf-2.6.0/python 目录下的google文件拷贝到/usr/lib/python2.7/dist-packages/目录下即可。

这里需要将你刚备份的文件google_back/protobuf/ 目录 descriptor_pb2.py  拷贝到google/protobuf/的目录下。


4.sudo pip install --upgrade protobuf

or

conda install -c https://conda.anaconda.org/anaconda protobuf

or

conda install protobuf==2.6.1


5. reinstall

sudo apt-get autoremove libprotobuf-dev protobuf-compiler

sudo apt-get install libprotobuf-dev protobuf-compiler


if u use the proto source code to install, then u need to uninstall in the same folder by reference with:

http://stackoverflow.com/questions/35896335/how-can-i-uninstall-protobuf-3-0-0
https://cmake.org/cmake/help/v3.0/module/FindProtobuf.html


你可能感兴趣的:(Caffe,Ubuntu)