tensorflow: TypeError: metaclass conflict in Python 2 and 3

TF 0.6.0 installed using PIP gives the following error on import in both Python 2 and 3:

>>> import tensorflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/.local/lib/python3.4/site-packages/tensorflow/__init__.py", line 23, in <module>
    from tensorflow.python import *
  File "/home/user/.local/lib/python3.4/site-packages/tensorflow/python/__init__.py", line 37, in <module>
    from tensorflow.core.framework.graph_pb2 import *
  File "/home/user/.local/lib/python3.4/site-packages/tensorflow/core/framework/graph_pb2.py", line 10, in <module>
    from google.protobuf import descriptor_pb2
  File "/home/user/.local/lib/python3.4/site-packages/google/protobuf/descriptor_pb2.py", line 1533, in <module>
    __module__ = 'google.protobuf.descriptor_pb2'
  File "/home/user/.local/lib/python3.4/site-packages/google/protobuf/reflection.py", line 123, in __new__
    new_class = superclass.__new__(cls, name, bases, dictionary)
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 19 (1 by maintainers)

Commits related to this issue

Most upvoted comments

sudo pip uninstall protobuf sudo pip install protobuf==3.0.0a3 (should be 3.0.0b2 if tensorflow’s version is 0.7.0, see @hsaito comment below) sudo pip uninstall tensorflow sudo pip install tensorflow-xxx-xxx.whl

Works for me. @PeterARBork