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>It looks like the only thing that is required is to include <code>google-cloud</code> into your project <code>requirements.txt</code> file.</p>

<p>Check if this simple sample works for you (you shouldn't get any imports error). 
Create below files and run <code>pip install -r requirements.txt -t lib</code>. Nothing more is required on my site to make it work.</p>

<p><strong>app.yaml</strong></p>

<pre><code>application: mysample
runtime: python27
api_version: 1
threadsafe: true

handlers:
  - url: /.*
    script: main.app
</code></pre>

<p><strong>main.py</strong></p>

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


class MainPage(webapp2.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.write('Hello, World!')

app = webapp2.WSGIApplication([
    ('/', MainPage),
], debug=True)
</code></pre>

<p><strong>appengine_config.py</strong></p>

<pre><code>from google.appengine.ext import vendor
import os

# Third-party libraries are stored in "lib", vendoring will make
# sure that they are importable by the application.
if os.path.isdir(os.path.join(os.getcwd(), 'lib')):
    vendor.add('lib')
</code></pre>

<p><strong>requirements.txt</strong></p>

<pre><code>google-cloud
</code></pre>

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