'import tensorflow' 后 python 中的错误:TypeError: __init__() 得到了一个意外的关键字参数 'syntax' [英] Error in python after 'import tensorflow': TypeError: __init__() got an unexpected keyword argument 'syntax'

查看:25
本文介绍了'import tensorflow' 后 python 中的错误:TypeError: __init__() 得到了一个意外的关键字参数 'syntax'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照仅针对 CPU 的说明在我的 Ubuntu 15.10 机器上安装了 TensorFlow:

I installed TensorFlow on my Ubuntu 15.10 machine as instructed for CPU only:

$ pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl

然后当我运行 Python REPL 并导入 tensorflow 时,我得到:

Then when I run the Python REPL and import tensorflow, I get:

$ python
Python 2.7.10 (default, Oct 14 2015, 16:09:02) 
[GCC 5.2.1 20151010] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/phil/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line 4, in <module>
   from tensorflow.python import *
  File "/home/phil/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 13, in <module>
    from tensorflow.core.framework.graph_pb2 import *
  File "/home/phil/.local/lib/python2.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 16, in <module>
    from tensorflow.core.framework import attr_value_pb2 as     tensorflow_dot_core_dot_framework_dot_attr__value__pb2
  File "/home/phil/.local/lib/python2.7/site-packages/tensorflow/core/framework/attr_value_pb2.py", line 16, in <module>
    from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
  File "/home/phil/.local/lib/python2.7/site-packages/tensorflow/core/framework/tensor_pb2.py", line 16, in <module>
    from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
  File "/home/phil/.local/lib/python2.7/site-packages/tensorflow/core/framework/tensor_shape_pb2.py", line 22, in <module>
    serialized_pb=_b('
,tensorflow/core/framework/tensor_shape.proto x12
tensorflow"d
x10TensorShapeProtox12-
x03x64imx18x02 x03(x0bx32 .tensorflow.TensorShapeProto.Dimx1a!
x03x44imx12x0c
x04sizex18x01 x01(x03x12x0c
x04namex18x02 x01(	bx06proto3')
TypeError: __init__() got an unexpected keyword argument 'syntax'

我安装了 Ubuntu protobuf-compiler 包,它的版本是 2.6.1-1.2

I have the Ubuntu protobuf-compiler package installed and it's version 2.6.1-1.2

推荐答案

一些用户报告了在安装旧版本 protobuf 时出现的问题.

Several users have reported issues that arise when an older version of protobuf is installed.

TensorFlow 需要(并使用其副本)protobuf-3.0.0a4.但是,它似乎与您安装的版本冲突(可能是由于您的系统上如何配置 PYTHONPATH 环境变量?).如果安装了python-protobuf包,可以尝试卸载它,然后查看TensorFlow是否正常启动吗?

TensorFlow requires (and uses a copy of) protobuf-3.0.0a4. However it seems to be conflicting with your installed version (perhaps due to how the PYTHONPATH environment variable is configured on your system?). Can you try uninstalling the python-protobuf package if it is installed, and then seeing if TensorFlow starts correctly?

一些用户在使用 virtualenv 时取得了成功.有关将 TensorFlow 安装到 virtualenv 的说明,请参阅入门指南.

Some users have had success when using a virtualenv. For instructions on installing TensorFlow into a virtualenv, see the getting started guide.

这篇关于'import tensorflow' 后 python 中的错误:TypeError: __init__() 得到了一个意外的关键字参数 'syntax'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆