[No module named 'google.appengine' appengine 本地开发报错

[No module named 'google.appengine' appengine local development error

我正在从 python27 迁移到 python37。我已将 python2 代码移植到 python3 代码。问题是当我尝试 运行 开发服务器时,它显示 ModuleNotFoundError: No module named 'google.appengine'。我下载了 google 云 SDK。

我还下载了以下 google 个库:

google==2.03google-api-core==1.17.0; google-auth==1.14.3; google-cloud==0.34.0; google-cloud-core==1.3.0; google-cloud-datastore==1.120; google-cloud-ndb==1.2.0; google-cloud-storage==1.28.0;

我正在使用CLOUD_DATASTORE。这跟那个有关系吗?我必须迁移吗?

这是完整的错误:

INFO     2020-05-12 15:58:51,741 instance_factory.py:261] Running /tmp/tmpAvEFgc/bin/pip install -r /tmp/tmpjm7s5D

INFO     2020-05-12 15:59:02,605 dispatcher.py:267] Starting module "default" running at: http://192.168.1.15:8080
INFO     2020-05-12 15:59:02,613 instance_factory.py:121] Detected Python 3.7.5

INFO     2020-05-12 15:59:03,607 instance.py:561] Cannot decide GOOGLE_CLOUD_PROJECT, using "test" as a fake value
[2020-05-12 11:59:03 -0400] [30089] [INFO] Starting gunicorn 20.0.4
[2020-05-12 11:59:03 -0400] [30089] [INFO] Listening at: http://0.0.0.0:21217 (30089)
[2020-05-12 11:59:03 -0400] [30089] [INFO] Using worker: sync
[2020-05-12 11:59:03 -0400] [30092] [INFO] Booting worker with pid: 30092
[2020-05-12 11:59:03 -0400] [30092] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/tmp/tmpAvEFgc/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
    worker.init_process()
  File "/tmp/tmpAvEFgc/lib/python3.7/site-packages/gunicorn/workers/base.py", line 119, in init_process
    self.load_wsgi()
  File "/tmp/tmpAvEFgc/lib/python3.7/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/tmp/tmpAvEFgc/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/tmp/tmpAvEFgc/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
    return self.load_wsgiapp()
  File "/tmp/tmpAvEFgc/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/tmp/tmpAvEFgc/lib/python3.7/site-packages/gunicorn/util.py", line 358, in import_app
    mod = importlib.import_module(module)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/vicktree/Documents/project-noah-3/noah-app/main.py", line 19, in <module>
    from handlers.noah_handler import NoahHandler
  File "/home/vicktree/Documents/project-noah-3/noah-app/handlers/noah_handler.py", line 16, in <module>
    from google.appengine.ext import db
ModuleNotFoundError: No module named 'google.appengine'

google.appengine 模块已融入第一代 Python (2.7) 运行时。在第二代 (3.7) 运行时或任何 Docker 环境中无法通过 pip 安装。

使用它的唯一方法是编写和部署第一代 App Engine 应用程序。

根据您的操作,您应该能够将其替换为客户端库调用。

有关详细信息,请参阅 https://cloud.google.com/appengine/docs/standard/python/migrate-to-python3