0

I've installed the protobuf package but I'm unable to import it.

> pip uninstall protobuf
... uninstalls
> pip install protobuf
... installs. confirm that it's installed:
pip install protobuf
Requirement already satisfied (use --upgrade to upgrade): protobuf in     ./.venv/lib/python3.5/site-packages
Requirement already satisfied (use --upgrade to upgrade): setuptools in ./.venv/lib/python3.5/site-packages (from protobuf)
Requirement already satisfied (use --upgrade to upgrade): six>=1.9 in ./.venv/lib/python3.5/site-packages (from protobuf)

Back in ipython:

In [1]: from google.protobuf import descriptor as _descriptor
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-3baca6afb060> in <module>()
----> 1 from google.protobuf import descriptor as _descriptor

ImportError: No module named google.protobuf

In [2]:

I'm really stumped.

> python --version
> Python 3.5.1

> which pip
/Users/skyler/work/TemplateProcessor/.venv/bin/pip
> pip --version
pip 8.1.2 from /Users/skyler/work/TemplateProcessor/.venv/lib/python3.5/site-packages (python 3.5)
skyler
  • 8,010
  • 15
  • 46
  • 69

1 Answers1

-1

I had the same issue and found a workaround suggested in this issue:

1.Adding a new file tensorflow/google/init.py:

try:
    import pkg_resources
    pkg_resources.declare_namespace(__name__)
except ImportError:
    import pkgutil
    __path__ = pkgutil.extend_path(__path__, __name__)

    Add namespace_packages to tensorflow/google/protobuf/python/setup.py:

setup(
    name='protobuf',
    namespace_packages=['google'],
    ...
)
  1. Recompile / pip install. Good luck!
Philip Kirkbride
  • 21,381
  • 38
  • 125
  • 225