Unable to use google-cloud in a GAE app
<p>The following line in my Google App Engine app (<code>webapp.py</code>) fails to import the <a href="https://googlecloudplatform.github.io/google-cloud-python/" rel="nofollow">Google Cloud</a> library:</p>

<pre><code>from google.cloud import storage
</code></pre>

<p>With the following error:</p>

<pre><code>ImportError: No module named google.cloud.storage
</code></pre>

<p>I did some research and found the following articles to be helpful:</p>

<ul>
<li><a href="https://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27#installing_a_library" rel="nofollow">https://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27#installing_a_library</a></li>
<li><a href="http://stackoverflow.com/a/34585485">http://stackoverflow.com/a/34585485</a></li>
<li><a href="https://www.simonmweber.com/2013/06/18/python-protobuf-on-app-engine.html" rel="nofollow">https://www.simonmweber.com/2013/06/18/python-protobuf-on-app-engine.html</a></li>
</ul>

<p>Using a combination of the techniques suggested by the above articles, I did the following:</p>

<ol>
<li><p>Create a <code>requirements.txt</code> file:</p>

<pre><code>google-cloud==0.19.0
</code></pre></li>
<li><p>Import this library using <code>pip</code>:</p>

<pre><code>pip install -t lib -r requirements.txt
</code></pre></li>
<li><p>Use the following code in my <code>appengine_config.py</code> file:</p>

<pre><code>import os
import sys
import google
libDir = os.path.join(os.path.dirname(__file__), "lib")
google.__path__.append(os.path.join(libDir, "google"))
sys.path.insert(0, libDir)
</code></pre></li>
</ol>

<p>Can anyone shed light on what I might be missing to get this working? I'm just trying to write a Google App Engine app that can write/read from Google Cloud Storage, and I'd like to test locally before deploying.</p>

<p>The package namespace seems to have been changed as pointed out in this <a href="https://github.com/GoogleCloudPlatform/google-cloud-python/pull/2264" rel="nofollow">github issue</a> and hasn't been fully fixed. You could install the older version (<code>pip install gcloud</code>) which uses a different namespace &amp; use this import statement instead:</p>

<pre><code>from gcloud import storage
</code></pre>

<p>You should also ensure that you're importing vendor libs in your appengine_config.py as pointed out in dyeray's answer.</p>

<p>The issue seems to have been fixed as at version 0.20.0 of google-cloud. So the import statement in the question should work. Just remember to run <code>pip install --upgrade google-cloud</code></p>

python google-app-engine google-cloud-storage google-cloud-platform