简体   繁体   English

导入caffe错误“语法”

[英]import caffe error 'syntax'

I can't pass pytest and fail to import caffe in python. 我无法通过pytest并且无法在python中导入caffe。

caffe in the direct \\Documents caffe直接在\\ Documents中

When I import caffe, the result are followed. 当我导入caffe时,将遵循结果。

>>> import caffe
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/james/Documents/caffe/python/caffe/__init__.py", line 1, in <module>
    from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
  File "/Users/james/Documents/caffe/python/caffe/pycaffe.py", line 15, in <module>
    import caffe.io
  File "/Users/james/Documents/caffe/python/caffe/io.py", line 8, in <module>
    from caffe.proto import caffe_pb2
  File "/Users/james/Documents/caffe/python/caffe/proto/caffe_pb2.py", line 23, in <module>
    1a\n\x0f\x64\x65t_context_pad\x18: \x01(\r:\x01\x30\x12\x1b\n\rdet_crop_mode\x18; \x01(\t:\x04warp\x12\x12\n\x07new_num\x18< \x01(\x05:\x01\x30\x12\x17\n\x0cnew_channels\x18= \x01(\x05:\x01\x30\x12\x15\n\nnew_height\x18> \x01(\x05:\x01\x30\x12\x14\n\tnew_width\x18? \x01(\x05:\x01\x30\x12\x1d\n\x0eshuffle_images\x18@ \x01(\x08:\x05\x66\x61lse\x12\x15\n\nconcat_dim\x18\x41 \x01(\r:\x01\x31\x12\x36\n\x11hdf5_output_param\x18\xe9\x07 \x01(\x0b\x32\x1a.caffe.HDF5OutputParameter\".\n\nPoolMethod\x12\x07\n\x03MAX\x10\x00\x12\x07\n\x03\x41VE\x10\x01\x12\x0e\n\nSTOCHASTIC\x10\x02\"W\n\x0ePReLUParameter\x12&\n\x06\x66iller\x18\x01 \x01(\x0b\x32\x16.caffe.FillerParameter\x12\x1d\n\x0e\x63hannel_shared\x18\x02 \x01(\x08:\x05\x66\x61lse*\x1c\n\x05Phase\x12\t\n\x05TRAIN\x10\x00\x12\x08\n\x04TEST\x10\x01')
TypeError: __init__() got an unexpected keyword argument 'syntax'

I dont know what's wrong. 我不知道怎么了。

This looks like a problem with protobuf - https://github.com/BVLC/caffe/issues/2092 这似乎是protobuf的问题-https: //github.com/BVLC/caffe/issues/2092

Have you installed protobuf 3.0? 您已经安装了protobuf 3.0吗? You may need to roll back to 2.6. 您可能需要回滚到2.6。

You could also unify the versions of python protobuf and protoc 您还可以统一python protobuf和protoc的版本

https://github.com/NVIDIA/DIGITS/issues/178 https://github.com/NVIDIA/DIGITS/issues/178

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM