1

I am trying to deploy a simple function using Python 3.7. My setup looks like this:

main.py

from firebase import firebase

def hello_world(request):
    if request.method == 'POST':
        return request.get_json().get('username')
    return f'Hello world!'

requirements.txt

# Function dependencies, for example:
# package>=version
requests==1.1.0
python-firebase==1.2

When deploying, I get this following error:

Deployment failure:
Function failed on loading user code. Error message: Code in file main.py can't be loaded.
Detailed stack trace: Traceback (most recent call last):
  File "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker.py", line 305, in check_or_load_user_function
    _function_handler.load_user_function()
  File "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker.py", line 184, in load_user_function
    spec.loader.exec_module(main)
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/user_code/main.py", line 1, in <module>
    from firebase import firebase
  File "/env/local/lib/python3.7/site-packages/firebase/__init__.py", line 3
    from .async import process_pool
              ^
SyntaxError: invalid syntax

How can I solve this issue? I have all the required dependencies listed. Any help is appreciated.

1 Answer 1

1

The python-firebase project was last released on March 21, 2014 by a third-party developer and doesn't support Python 3.7. Specifically it uses the new reserved keywords async/await.

You probably want to use the google-cloud-firestore client library instead, which is maintained and supported by Google.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.