python-3.xgoogle-app-enginepyrebase

Cannot import pyrebase GAE


I have an application which works perfectly locally. But, for some reason, in GAE (standard python37) it seems to have an issue importing pyrebase (pyrebase==3.0.27 in requirements.txt). Any idea how to fix this?

Thanks in advance!

Traceback (most recent call last):
  File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
    worker.init_process()
  File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
    self.load_wsgi()
  File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
    return self.load_wsgiapp()
  File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
    __import__(module)
  File "/workspace/main.py", line 8, in <module>
    import pyrebase
  File "/layers/google.python.pip/pip/lib/python3.7/site-packages/pyrebase/__init__.py", line 1, in <module>
    from .pyrebase import initialize_app
  File "/layers/google.python.pip/pip/lib/python3.7/site-packages/pyrebase/pyrebase.py", line 17, in <module>
    from oauth2client.service_account import ServiceAccountCredentials
  File "/layers/google.python.pip/pip/lib/python3.7/site-packages/oauth2client/service_account.py", line 25, in <module>
    from oauth2client import client
  File "/layers/google.python.pip/pip/lib/python3.7/site-packages/oauth2client/client.py", line 47, in <module>
    from oauth2client import crypt
  File "/layers/google.python.pip/pip/lib/python3.7/site-packages/oauth2client/crypt.py", line 55, in <module>
    from oauth2client import _pycrypto_crypt
  File "/layers/google.python.pip/pip/lib/python3.7/site-packages/oauth2client/_pycrypto_crypt.py", line 17, in <module>
    from Crypto.PublicKey import RSA
  File "/layers/google.python.pip/pip/lib/python3.7/site-packages/Crypto/PublicKey/__init__.py", line 29, in <module>
    from Crypto.Util.asn1 import (DerSequence, DerInteger, DerBitString,
  File "/layers/google.python.pip/pip/lib/python3.7/site-packages/Crypto/Util/asn1.py", line 33, in <module>
    from Crypto.Util.number import long_to_bytes, bytes_to_long
  File "/layers/google.python.pip/pip/lib/python3.7/site-packages/Crypto/Util/number.py", line 398
    s = pack('>I', n & 0xffffffffL) + s

SyntaxError: invalid syntax

Solution

  • Pyrebase 3.0.27 is having compatibility issue with Python version 3. Instead, use the latest version of Pyrebase: Pyrebase4.

    The OP solved the problem by changing Pyrebase version in requirements.txt:

    From pyrebase==3.0.27 to Pyrebase4==4.5.0