tensorboard: ImportError: cannot import name '_message' from 'google.protobuf.pyext' (/usr/lib/python3.7/site-packages/google/protobuf/pyext/__init__.py)

  • TensorBoard version: tensorboard-1.12.0
  • GNU/Linux, Manjaro
  • Python version: 3.7.1

Issue: Just calling tensorboard fails to load. A bug with protobuf?

Traceback (most recent call last):
  File "/usr/bin/tensorboard", line 11, in <module>
    load_entry_point('tensorboard==1.12.0', 'console_scripts', 'tensorboard')()
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 484, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2725, in load_entry_point
    return ep.load()
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2343, in load
    return self.resolve()
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2349, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3.7/site-packages/tensorboard/main.py", line 45, in <module>
    from tensorboard import default
  File "/usr/lib/python3.7/site-packages/tensorboard/default.py", line 34, in <module>
    import tensorflow as tf
  File "/usr/lib/python3.7/site-packages/tensorflow/__init__.py", line 22, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "/usr/lib/python3.7/site-packages/tensorflow/python/__init__.py", line 52, in <module>
    from tensorflow.core.framework.graph_pb2 import *
  File "/usr/lib/python3.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 6, in <module>
    from google.protobuf import descriptor as _descriptor
  File "/usr/lib/python3.7/site-packages/google/protobuf/descriptor.py", line 47, in <module>
    from google.protobuf.pyext import _message
ImportError: cannot import name '_message' from 'google.protobuf.pyext' (/usr/lib/python3.7/site-packages/google/protobuf/pyext/__init__.py)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 13
  • Comments: 23

Most upvoted comments

Found a solution here: https://stackoverflow.com/a/50950265

export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
sudo pip install --upgrade --force-reinstall protobuf

There’s a recent release of protobuf in Feb (3.7.0rc2), although it’s still a RC build. Install that and it should solve the issue. I’ve tested this on Python 3.7.1 + TensorBoard 1.12.2

Found a solution here: https://stackoverflow.com/a/50950265

export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
sudo pip install --upgrade --force-reinstall protobuf

I just want to add, even if you’re using a conda environment, you still have to do this through pip. I was on Windows, and ran: pip install --upgrade --force-reinstall protobuf to great success. Thanks again!

I met this problem at tensorboard 1.12.0 and I solved it by downgrading tensorboard to 1.11.0.

I’m using arch linux, and this problem seems to start from tensorboard 1.11.0 and is still not solved by now. My solution is that using downgrade(from AUR) to manually downgrade tensorboard to 1.10.0, which is the last working version.

https://bugs.archlinux.org/task/54959

Please don’t break your system with sudo pip, by the way.

Like @chroteus said, it is an issue with the CPP implementation of protobuf not being compiled for python 3.7 yet: https://github.com/protocolbuffers/protobuf/issues/5154 For Arch users (and others that need to use python3.7), we have to wait, installing from pip doesn’t help.

I have it installed it using Arch’s package manager (Pacman). Pacman pulls C++ implementation of protobuf as a dependency of python-protobuf anyway, so it doesn’t seem to be the case. Version - python-protobuf: 3.6.1-1

I will try uninstalling with Pacman and see if installing everything through pip will work.

EDIT: It seems the issue is with me using Python 3.7. I will downgrade and see if this is the case. EDIT2: Downgrading messes up other packages that require Py3.7, so I guess we’ll wait until Py3.7 is fully supported.

The latest version that seems to work is tensorboard-1.11.0-2.

Another ArchLinux guy with the same issue. Fixed by updating python-protobuf from testing repo (released there on Dec 26th), just in case someone needs it urgently. But since it’s already in testing the stable package should be available soon.

I have the same issue. from google.protobuf.empty_pb2 import Empty; Empty.FromString(b'') doesn’t cause any problem.