Mads Jensen
Mads Jensen

Reputation: 87

Crypto.Util import error in firebase_helper.py 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 firebase_helper.py. 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/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 <module>
    import firebase_helper
  File "/home/vmagent/app/firebase_helper.py", line 20, in <module>
    from Crypto.Util import asn1
ImportError: No module named Crypto.Util

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

libraries:
- 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?

Upvotes: 1

Views: 210

Answers (1)

atimothee
atimothee

Reputation: 658

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 :

pycrypto==2.6.1

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

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

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

Upvotes: 2

Related Questions