简体   繁体   English

意外属性 app_engine_apis 错误部署 Python 3 App Engine Flask 应用程序

[英]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 中使用捆绑服务:

  1. Add app_engine_apis: true to app.yaml添加app_engine_apis: trueapp.yaml
  2. Add appengine-python-standard to requirements.txtappengine-python-standard添加到requirements.txt
  3. Import the WSGI wrapper: from google.appengine.api import wrap_wsgi_app导入 WSGI 包装器: from google.appengine.api import wrap_wsgi_app
  4. Wrap your WSGI object (Flask): app = Flask(__name__); app.wsgi_app = wrap_wsgi_app(app.wsgi_app)包装你的 WSGI object (Flask): app = Flask(__name__); app.wsgi_app = wrap_wsgi_app(app.wsgi_app) app = Flask(__name__); app.wsgi_app = wrap_wsgi_app(app.wsgi_app)
  5. Review these instructions , esp.查看这些说明,尤其是。 if you're not using Flask如果你使用 Flask
  6. Update your Cloud SDK : gcloud components update更新您的 Cloud SDKgcloud 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.

相关问题 将app.yaml从go114更新到go115时如何处理`app_engine_apis`警告 - How to deal with `app_engine_apis` warning when updating app.yaml from go114 to go115 在 Google App Engine 中部署 Flask 应用程序导致“gunicorn:错误:未指定应用程序模块。” - Deploying Flask app in Google App Engine resulting in "gunicorn: error: No application module specified." 在 gcloud 应用引擎上运行 Python Flask 应用程序的延迟非常高 - Very high latency running Python Flask app on gcloud app engine 除了在 Google App Engine Flex 环境中部署 python flask 应用程序之外,还有其他替代方法吗? - Is there any alternative approach other than deploying python flask application in Google app engine flex environment? 将 Laravel 应用程序部署到 Google App Engine - Deploying Laravel app to Google App Engine 部署应用引擎后的暂存文件桶 - Bucket of Staging files after deploying an app engine 在 App Engine 中部署 Django 时出现 OSError - OSError while deploying Django in App Engine 从命令行部署 App Engine 标准项目时出错 - Error while deploying App Engine standard project from command line 从 GitLab CI 将应用程序部署到 App Engine 时权限被拒绝 - Permission denied while deploying an app to App Engine from GitLab CI Google App Engine ModuleHostname:不是 App Engine 上下文 - Google App Engine ModuleHostname: not an App Engine context
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM