When using python's caffe, the following problems occur:
Failed to include caffe_pb2, things might go wrong!
Traceback (most recent call last):
File "caffe/python/draw_net.py", line 8, in <module>
import caffe
File "/home/caffe/python/caffe/__init__.py", line 4, in <module>
from .proto.caffe_pb2 import TRAIN, TEST
File "/home/caffe/python/caffe/proto/caffe_pb2.py", line 17, in <module>
serialized_pb=''# 一个很长的字符串,太长了,就不贴上来了
File "/usr/local/anaconda3/lib/python3.5/site-packages/google/protobuf/descriptor.py", line 879, in __new__
return _message.default_pool.AddSerializedFile(serialized_pb)
TypeError: expected bytes, str found
Refer to " caffe cpu version Anaconda3 python interface installation ", guess the original protobuf
may only be used python2
, so I decided to reinstall the python3
usable protobuf :
~$ # 先卸载旧版本
~$ sudo pip uninstall protobuf
~$ # 再安装py3版本
~$ sudo pip install protobuf-py3
The problem was resolved afterwards.