Skip to content

virtualenv python 2.7.6 import tensorflow. TypeError: __init__() got an unexpected keyword argument 'syntax' #57

Closed

Description

@liuyipei

I am running inside a virtual env and followed the given instructions. The following problem is consistent whether I compile from scratch or use the whl from the provided Internet link.

Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> import tensorflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/mnt/4tb_internal/python/tensorflow/local/lib/python2.7/site-packages/tensorflow/__init__.py", line 4, in <module>
    from tensorflow.python import *
  File "/mnt/4tb_internal/python/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 13, in <module>
    from tensorflow.core.framework.graph_pb2 import *
  File "/mnt/4tb_internal/python/tensorflow/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 "/mnt/4tb_internal/python/tensorflow/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 "/mnt/4tb_internal/python/tensorflow/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 "/mnt/4tb_internal/python/tensorflow/local/lib/python2.7/site-packages/tensorflow/core/framework/tensor_shape_pb2.py", line 22, in <module>
    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')
TypeError: __init__() got an unexpected keyword argument 'syntax'
>>> 

Here is the output to pip show numpy protobuf

Name: numpy
Version: 1.10.1
Location: /mnt/4tb_internal/python/tensorflow/lib/python2.7/site-packages
Requires: 

Name: protobuf
Version: 3.0.0a3
Location: /mnt/4tb_internal/python/tensorflow/lib/python2.7/site-packages
Requires: setuptools

Here is the output to uname -a. My machine runs Ubuntu 14.04 LTS.

Linux yi-2014 3.13.0-64-generic #104-Ubuntu SMP Wed Sep 9 12:36:12 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Activity

  1. vrv commented on Nov 10, 2015

    @vrv

    Likely a dupe of #11 -- see the solutions near the very end to see if they help. Thanks!

  2. reopened this on Nov 10, 2015
  3. liuyipei commented on Nov 10, 2015

    @liuyipei
    ContributorAuthor

    I removed libprotoc and followed instructions from https://github.com/google/protobuf and installed the new beta version of protoc 3.0.

    Here is the output to protoc --version

    (tensorflow)yiliu@yi-2014:~$ protoc --version
    libprotoc 3.0.0
    

    I then reinstalled tensorflow, but the output persists.

  4. vrv commented on Nov 10, 2015

    @vrv

    It's probably something to do with the path -- can you verify that there are no other protobuf libraries on your system that might be interfering? This problem only occurs when it's using the proto2 version of the python libraries: our python generated files use python3.

    To help debug, maybe also try to print the version of the protobuf library when in python?

    import google.protobuf
    print google.protobuf.__version__

    or something like that?

  5. liuyipei commented on Nov 10, 2015

    @liuyipei
    ContributorAuthor

    Thank you for your help.
    google.protobuf.__version__ was not defined, thereby confirming your suspicion about paths.

    To fix my issue:
    I exited the tensorflow virtualenv and returned to my default env. Then, I did sudo pip uninstall protobuf.

  6. added 2 commits that reference this issue on Mar 9, 2016
  7. added a commit that references this issue on Feb 20, 2018
  8. added a commit that references this issue on Mar 3, 2023
    04ea1a5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions