Tensorflow导入出错 | Error occured when import tensorflow: TypeError: __init__() got an unexpected keyword argument 'file'

Error Infomation

1
2
3
4
5
6
7
8
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tensorflow/core/framework/resource_handle_pb2.py in <module>()
39 message_type=None, enum_type=None, containing_type=None,
40 is_extension=False, extension_scope=None,
---> 41 options=None, file=DESCRIPTOR),
42 _descriptor.FieldDescriptor(
43 name='container', full_name='tensorflow.ResourceHandleProto.container', index=1,

TypeError: __init__() got an unexpected keyword argument 'file'

Environment

  • Tensorflow 1.6
  • Protobuf(installed by pip) 3.5.2.post1
  • Protobuf(installed by brew) 3.3.0

Reason

The protobuf package version mismatch with tensorflow.

And I, don’t know when, installed protobuf 3.3.0 by brew.

The latest protobuf(3.5.2.post1) install by pip doesn’t disturbing tensorflow.

Solution

1
brew uninstall protobuf

Run this in terminal to uninstall the hidden protobuf and everything get well.

Tipping