问题:安装tensorflow遇到 TypeError: __init__() got an unexpected keyword argument 'syntax'

安装完Tensorflow后,测试是否可用时,执行

>>> import tensorflow as tf

报错

Traceback (most recent call last):
  File "", line 1, in 
  File "/anaconda2/lib/python2.7/site-packages/tensorflow/__init__.py", line 4, in 
    from tensorflow.python import *
  File "/anaconda2/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 13, in 
    from tensorflow.core.framework.graph_pb2 import *
  File "/anaconda2/lib/python2.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 16, in 
    from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
  File "/anaconda2/lib/python2.7/site-packages/tensorflow/core/framework/attr_value_pb2.py", line 16, in 
    from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
  File "/anaconda2/lib/python2.7/site-packages/tensorflow/core/framework/tensor_pb2.py", line 16, in 
    from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
  File "/anaconda2/lib/python2.7/site-packages/tensorflow/core/framework/tensor_shape_pb2.py", line 22, in 
    serialized_pb=_b('\n,tensorflow/core/framework/tensor_shape.proto\x12\ntensorflow\"d\n\x10TensorShapeProto\x12-\n\x03\x64im\x18\x02 \x03(\x0b\x32 .tensorflow.TensorShapeProto.Dim\x1a!\n\x03\x44im\x12\x0c\n\x04size\x18\x01 \x01(\x03\x12\x0c\n\x04name\x18\x02 \x01(\tb\x06proto3')

度娘一番,说是protobuf版本太低,解决方案如下:

$ pip install --upgrade protobuf

更新完成后,再次切到ptyhon环境中测试,OK

你可能感兴趣的:(问题:安装tensorflow遇到 TypeError: __init__() got an unexpected keyword argument 'syntax')