[英]Unexpected attribute app_engine_apis error deploying Python 3 App Engine Flask app
I use Google App Engine standard environemment with Flask Python3 for a current project.我将 Google App Engine 标准环境与 Flask Python3 一起用于当前项目。 This project use as cache the App Engine Memcache (google.appengine.api.memcache).
该项目使用 App Engine Memcache (google.appengine.api.memcache) 作为缓存。
Currently the cache doesn't work and I think that it's probably because of the dependency on App Engine APIs that need to be enable because when I try to deploy my app (gcloud app deploy) I have this warning: WARNING: There is a dependency on App Engine APIs, but they are not enabled in your app.yaml. Set the app_engine_apis property.
目前缓存不起作用,我认为这可能是因为需要启用对 App Engine API 的依赖性,因为当我尝试部署我的应用程序(gcloud app deploy)时,我收到此警告:
WARNING: There is a dependency on App Engine APIs, but they are not enabled in your app.yaml. Set the app_engine_apis property.
WARNING: There is a dependency on App Engine APIs, but they are not enabled in your app.yaml. Set the app_engine_apis property.
My issue is that when I try to set the dependancy in my app.yaml and deploy, I have then this error: Unexpected attribute 'app_engine_apis' for object of type AppInfoExternal.
我的问题是,当我尝试在我的 app.yaml 中设置依赖项并进行部署时,出现此错误:
Unexpected attribute 'app_engine_apis' for object of type AppInfoExternal.
I also tried with the exact same yaml file than the Google example: https://github.com/googlecodelabs/migrate-python2-appengine/blob/master/mod12b-memcache/app.yaml , it doesn't work.我还尝试使用与 Google 示例完全相同的 yaml 文件: https://github.com/googlecodelabs/migrate-python2-appengine/blob/master/mod12b-memcache/app.yaml ,它不起作用。
Here the current app.yaml that I'm trying to use:这是我正在尝试使用的当前 app.yaml:
runtime: python39
env: standard
app_engine_apis: true
resources:
cpu: 2
memory_gb: 4
disk_size_gb: 15
manual_scaling:
instances: 2
This issue is almost the same as this question but I couldn't use it to solve my problem: How to deal with `app_engine_apis` warning when updating app.yaml from go114 to go115这个问题几乎与这个问题相同,但我无法用它来解决我的问题: How to deal with `app_engine_apis` warning when updating app.yaml from go114 to go115
Thank you for your help.谢谢您的帮助。
Your version of gcloud probably means the app_engine_apis are in the beta version and so you have to do您的 gcloud 版本可能意味着 app_engine_apis 处于测试版,因此您必须这样做
gcloud beta app deploy
Your Google Cloud SDK is outdated.您的Google Cloud SDK已过时。 Per the comments in @NoCommandLine 's answer, your SDK being version 300 is from Jul 2020 whereas the bundled services for 2nd-gen runtimes like Python 3 didn't go into private preview until Jun 2021. They became generally available in Sep 2021 .
根据@NoCommandLine的回答中的评论,您的 SDK 版本 300 是从 2020 年 7 月开始的,而像 Python 3 这样的第二代运行时的捆绑服务直到 2021 年 6 月才 go 进入私人预览版。它们在 2021 年 9 月普遍可用。 If you run
gcloud components update
to get the latest SDK (at the time of this post, it's 410), you should be able to run gcloud app deploy
to deploy a Python 3 App Engine app that can access the Memcache bundled service .如果您运行
gcloud components update
以获取最新的 SDK(在撰写本文时为 410),您应该能够运行gcloud app deploy
以部署一个 Python 3 App Engine 应用程序,该应用程序可以访问Memcache 捆绑服务。 TL;DR to using bundled services in Python 3: TL;DR在 Python 3 中使用捆绑服务:
app_engine_apis: true
to app.yaml
app_engine_apis: true
到app.yaml
appengine-python-standard
to requirements.txt
appengine-python-standard
添加到requirements.txt
from google.appengine.api import wrap_wsgi_app
from google.appengine.api import wrap_wsgi_app
app = Flask(__name__); app.wsgi_app = wrap_wsgi_app(app.wsgi_app)
app = Flask(__name__); app.wsgi_app = wrap_wsgi_app(app.wsgi_app)
app = Flask(__name__); app.wsgi_app = wrap_wsgi_app(app.wsgi_app)
gcloud components update
gcloud components update
NOTE: You no longer need to run
pip install -t lib -r requirements.txt
to vendor/self-bundle package dependencies... they're now automatically installed for Py3 users (but not Py2 though) when you deploy your app to the cloud.注意:您不再需要运行
pip install -t lib -r requirements.txt
to vendor/self-bundle package dependencies...当您将应用程序部署到云端。
I recently published a video & codelab (hands-on tutorial) on how to access the bundled services from "Gen2" but realize now I should've mentioned updating your SDK, meaning it covers almost all of the instructions above.我最近发布了一个关于如何从“Gen2”访问捆绑服务的视频和代码实验室(动手教程),但现在意识到我应该提到更新您的 SDK,这意味着它几乎涵盖了上述所有说明。
:P
For those interested in eventually migrating off Memcache to something more powerful like Redis, I also published content on migrating from Memcache to Cloud Memorystore for Redis , relatively recently as well.对于那些有兴趣最终从 Memcache 迁移到更强大的东西(如 Redis)的人,我还发布了有关从 Memcache 迁移到 Cloud Memorystore for Redis 的内容,也是最近。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.