Mads Jensen Mads Jensen - 18 days ago 8
Python Question

Crypto.Util import error in when deploying to Google App Flexible Engine

I have been working to deploy the Authenticating Users on App Engine Using Firebase tutorial, and can successfully deploy this to my local machine.

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

vm: true

the frontend deploys fine to the flexible app engine, but the backend throws an error during the import of Specifically, it is choking on this line:

from Crypto.Util import asn1

The raw stacktrace is listed here:

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

Now, pycrypto is already included in the app.yaml:

- name: ssl
version: 2.7.11
- name: pycrypto
version: 2.6.1

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.

Any idea why I get this error during deployment?


According to the Google App engine documentation, the libraries section of app.yaml is no longer supported in flexible VM. You will need to declare dependencies in requirements.txt.

So, you need to add this line to your requirements.txt :


Make sure you delete the libraries directive from your app.yaml

Make sure your runtime is set to runtime: python-compat.

Delete the file, since the flexible vm automatically installs all dependencies in the requirements.txt.