"ImportError: No module named google.protobuf" but it's definitely installed
<p>I've installed the <code>protobuf</code> package but I'm unable to import it.</p>

<pre><code>&gt; pip uninstall protobuf
... uninstalls
&gt; 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&gt;=1.9 in ./.venv/lib/python3.5/site-packages (from protobuf)
</code></pre>

<p>Back in <code>ipython</code>:</p>

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

ImportError: No module named google.protobuf

In [2]:
</code></pre>

<p>I'm really stumped.</p>

<pre><code>&gt; python --version
&gt; Python 3.5.1

&gt; which pip
/Users/skyler/work/TemplateProcessor/.venv/bin/pip
&gt; pip --version
pip 8.1.2 from /Users/skyler/work/TemplateProcessor/.venv/lib/python3.5/site-packages (python 3.5)
</code></pre>

<p>I had the same issue and found a workaround suggested in <a href="https://github.com/tensorflow/tensorflow/issues/1415" rel="nofollow">this issue</a>: </p>

<blockquote>
  <p>1.Adding a new file tensorflow/google/init.py:</p>

<pre><code>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'],
    ...
)
</code></pre>
  
  <ol start="2">
  <li>Recompile / pip install. Good luck!</li>
  </ol>
</blockquote>

python protocol-buffers python-3.5