简体   繁体   English

使用依赖项使用 Google Cloud Functions 部署 Python 函数时出错

[英]Error deploying Python function using Google Cloud Functions using dependencies

I am trying to deploy a simple function using Python 3.7.我正在尝试使用 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要求.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.任何帮助表示赞赏。

The python-firebase project was last released on March 21, 2014 by a third-party developer and doesn't support Python 3.7. python-firebase项目最后一次由第三方开发人员于 2014 年 3 月 21 日发布,不支持 Python 3.7。 Specifically it uses the new reserved keywords async / await .具体来说,它使用新的保留关键字async / await

You probably want to use the google-cloud-firestore client library instead, which is maintained and supported by Google.您可能希望改用由 Google 维护和支持的google-cloud-firestore客户端库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python 中的 Google Cloud Function 在部署时出现错误 - Google Cloud Function in Python gives an error on deploying 从控制台或 console.cloud.google.com/functions/edit 部署 Python GCP 云函数时出现 INVALID_ARGUMENT 错误 - INVALID_ARGUMENT error when deploying Python GCP Cloud Function from either console or console.cloud.google.com/functions/edit 使用 Google Cloud Functions 安装具有依赖项的软件包 - Install packages that have dependencies using Google Cloud Functions Python flask 应用使用谷歌云功能 - Python flask app using google cloud functions 部署 Google Cloud Functions - Deploying Google Cloud Functions 使用 Google 云功能写入 Google Cloud Spanner 时出错 - Error on writing to Google cloud spanner using Google cloud functions 在作为 Google Cloud Function 运行的 Python 脚本中使用 gcloud 命令时出错 - Error using gcloud command in Python script running as Google Cloud Function 轻量级的ETL,将Google Cloud Storage和Cloud Functions与Python 3.7结合使用 - lightweight ETL using Google Cloud Storage and Cloud Functions with Python 3.7 部署到 Google Cloud Function:错误消息:&#39;main&#39; - Deploying to Google Cloud Function: Error message: 'main' 在 Google Cloud Function 中为 Google Cloud Storage 使用 compose 时出现 404 错误 - 404 Error using compose for Google Cloud Storage in Google Cloud Function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM