NameError: name 'unicode' is not defined when compile with python3

544 views
Skip to first unread message

Md adnan alam khan

unread,
Oct 29, 2015, 3:11:29 PM10/29/15
to Caffe Users
I am trying to compiled caffe with python3. After the compilation when I am trying to import caffe I am getting follwing error

In [1]: import caffe
Failed to include caffe_pb2, things might go wrong!
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-1cca3aa1f8c5> in <module>()
----> 1 import caffe

/library_install_dir/caffe/python/caffe/__init__.py in <module>()
      1 from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
      2 from ._caffe import set_mode_cpu, set_mode_gpu, set_device, Layer, get_solver, layer_type_list
----> 3 from .proto.caffe_pb2 import TRAIN, TEST
      4 from .classifier import Classifier
      5 from .detector import Detector

/library_install_dir/caffe/python/caffe/proto/caffe_pb2.py in <module>()
    975       name='type', full_name='caffe.FillerParameter.type', index=0,
    976       number=1, type=9, cpp_type=9, label=1,
--> 977       has_default_value=True, default_value=unicode("constant", "utf-8"),
    978       message_type=None, enum_type=None, containing_type=None,
    979       is_extension=False, extension_scope=None,

NameError: name 'unicode' is not defined

* The issue is Python 3 renamed the unicode type to str, the old str type has been replaced by bytes. 

I tried to modify the proto/caffe_pb2 but it is not working. 

Anyone having similar issue with caffe. I have a working caffe with python3 support in my bare metal Now I am trying to dockerize it.

Thanks in advance.
Adnan 
Reply all
Reply to author
Forward
0 new messages