[英]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.