Failed to include caffe_pb2, things might go wrong! ... TypeError: expected bytes, str found

使用python的caffe的时候,出现下面的问题:

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

参考了一下《caffe cpu版 Anaconda3 python 接口安装》,猜测原装的protobuf可能只能用于python2,所以决定重新安装python3能用的protobuf

~$ # 先卸载旧版本
~$ sudo pip uninstall protobuf
~$ # 再安装py3版本
~$ sudo pip install protobuf-py3

之后问题得到解决。

猜你喜欢

转载自blog.csdn.net/qq_29695701/article/details/100542775