App Engine Python 2.7 - ImportError: cannot import name apiproxy

App Engine Python 2.7 - ImportError: cannot import name apiproxy

随着升级到 Google Cloud SDK 360.0.0-0,当 运行 我的 Python 2.7 App Engine 的 dev_appserver.py 命令时,我开始看到以下错误项目。

  File "/home/..................py", line 6, in <module>
    from google.appengine.ext import ndb
  File "/usr/lib/google-cloud-sdk/platform/google_appengine/python27/sdk/google/appengine/ext/ndb/__init__.py", line 22, in <module>
    from tasklets import *
  File "/usr/lib/google-cloud-sdk/platform/google_appengine/python27/sdk/google/appengine/ext/ndb/tasklets.py", line 85, in <module>
    from .google_imports import apiproxy_stub_map
  File "/usr/lib/google-cloud-sdk/platform/google_appengine/python27/sdk/google/appengine/ext/ndb/google_imports.py", line 44, in <module>
    from google.appengine.runtime import apiproxy as callback
ImportError: cannot import name apiproxy

gcloud 版本

Google Cloud SDK 360.0.0
alpha 2021.10.04
app-engine-python 1.9.95
app-engine-python-extras 1.9.95
beta 2021.10.04
bq 2.0.71
cloud-build-local 0.5.2
cloud-datastore-emulator 2.1.0
core 2021.10.04
gsutil 5.3

编辑

此问题似乎已通过 Google Cloud SDK 版本 371

得到解决

在我基于 debian 的系统上,我通过将 app-engine-python 组件降级到以前的版本来修复它

sudo apt-get install google-cloud-sdk-app-engine-python=359.0.0-0
sudo apt-get install google-cloud-sdk-app-engine-python-extras=359.0.0-0

gcloud版本(降级后)

Google Cloud SDK 360.0.0
alpha 2021.10.04
app-engine-python 1.9.94
app-engine-python-extras 1.9.95
beta 2021.10.04
bq 2.0.71
cloud-build-local 0.5.2
cloud-datastore-emulator 2.1.0
core 2021.10.04
gsutil 5.3

我为这个错误创建了一个问题:https://issuetracker.google.com/issues/202171426

对于windows你可以试试这个

gcloud components update --version 355.0.0

Google-cloud-sdk version 364 还是没有解决。 Windows 或 mac 用户可以试试这个:

gcloud components update --version 359.0.0

(359版本还包括'app-engine-python-extras'=1.9.94,所以效果很好。)