Crypto.Util import error in firebase_helper.py when deploying to Google App Flexible Engine
<p>I have been working to deploy the <a href="https://cloud.google.com/appengine/docs/python/authenticating-users-firebase-appengine" rel="nofollow">Authenticating Users on App Engine Using Firebase</a> tutorial, and can successfully deploy this to my local machine. </p>

<p>As I wish to test some python modules that don't run on the standard Google App Engine, I have now tried to deploy this to the Flexible Environment via this setting in app.yaml</p>

<pre><code>vm: true
</code></pre>

<p>the frontend deploys fine to the flexible app engine, but the backend throws an error during the import of firebase_helper.py. Specifically, it is choking on this line: </p>

<pre><code>from Crypto.Util import asn1
</code></pre>

<p>The raw stacktrace is listed here: </p>

<pre><code>Traceback (most recent call last):
  File "/home/vmagent/python_vm_runtime/google/appengine/ext/vmruntime/meta_app.py", line 550, in GetUserAppAndServe
    app, mod_file = self.GetUserApp(script)
  File "/home/vmagent/python_vm_runtime/google/appengine/ext/vmruntime/meta_app.py", line 411, in GetUserApp
    app = _AppFrom27StyleScript(script)
  File "/home/vmagent/python_vm_runtime/google/appengine/ext/vmruntime/meta_app.py", line 271, in _AppFrom27StyleScript
    app, filename, err = wsgi.LoadObject(script)
  File "/home/vmagent/python_vm_runtime/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/home/vmagent/app/main.py", line 22, in &lt;module&gt;
    import firebase_helper
  File "/home/vmagent/app/firebase_helper.py", line 20, in &lt;module&gt;
    from Crypto.Util import asn1
ImportError: No module named Crypto.Util
</code></pre>

<p>Now, pycrypto is already included in the app.yaml:</p>

<pre><code>libraries:
- name: ssl
  version: 2.7.11
- name: pycrypto
  version: 2.6.1
</code></pre>

<p>I have SSH'd into the server, and Crypto is installed. I can also load it into a python console on the VM, without problems. </p>

<p>Any idea why I get this error during deployment? </p>

<p>According to the <a href="https://cloud.google.com/appengine/docs/flexible/python/migrating-an-existing-app" rel="nofollow">Google App engine documentation</a>, the libraries section of app.yaml is no longer supported in flexible VM. You will need to declare dependencies in requirements.txt.</p>

<p>So, you need to add this line to your <code>requirements.txt</code> :</p>

<pre><code>pycrypto==2.6.1
</code></pre>

<p>Make sure you delete the <code>libraries</code> directive from your app.yaml</p>

<p>Make sure your runtime is set to <code>runtime: python-compat</code>.</p>

<p>Delete the appengine_cfg.py file, since the flexible vm automatically installs all dependencies in the <code>requirements.txt</code>.</p>

python google-app-engine firebase