SQL-在 Google App Engine 上找不到 Alchemy 模块错误

SQL-Alchemy Module Not Found Error on Google App Engine

我正尝试在 Google Cloud 上运行我的第一个 App Engine,但我遇到了问题。我在网上没有找到任何回应。

在标准环境下,这是我的 app.yaml :

runtime: python38
handlers:
  # This configures Google App Engine to serve the files in the app's static
  # directory.
- url: /static
  static_dir: static

  # This handler routes all requests not caught above to your main app. It is
  # required when static routes are defined, but can be omitted (along with
  # the entire handlers section) when there are no static files defined.
- url: /.*
  script: auto

这是我的 requirements.txt :

flask==1.1.2
werkzeug==1.0.1
sqlalchemy==1.3.18
flask_sqlalchemy==2.4.4
pymysql==0.10.0

错误信息:

Traceback (most recent call last):    
File "/layers/google.python.webserver/gunicorn/gunicorn/arbiter.py", line 583, in spawn_worker      worker.init_process()    
File "/layers/google.python.webserver/gunicorn/gunicorn/workers/gthread.py", line 92, in init_process      super().init_process()    
File "/layers/google.python.webserver/gunicorn/gunicorn/workers/base.py", line 119, in init_process      self.load_wsgi()    
File "/layers/google.python.webserver/gunicorn/gunicorn/workers/base.py", line 144, in load_wsgi      self.wsgi = self.app.wsgi()    
File "/layers/google.python.webserver/gunicorn/gunicorn/app/base.py", line 67, in wsgi      self.callable = self.load()    
File "/layers/google.python.webserver/gunicorn/gunicorn/app/wsgiapp.py", line 49, in load      return self.load_wsgiapp()    
File "/layers/google.python.webserver/gunicorn/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp      return util.import_app(self.app_uri)    
File "/layers/google.python.webserver/gunicorn/gunicorn/util.py", line 358, in import_app      mod = importlib.import_module(module)    
File "/opt/python3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module      return _bootstrap._gcd_import(name[level:], package, level)    
File "<frozen importlib._bootstrap>", line 1014, in
_gcd_import    
File "<frozen importlib._bootstrap>", line 991, in _find_and_load    
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked    
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked    
File "<frozen importlib._bootstrap_external>", line 783, in exec_module    
File "<frozen importlib._bootstrap>", line 219, in
_call_with_frames_removed    
File "/srv/main.py", line 2, in <module>      from tmfapp import app    
File "/srv/tmfapp/__init__.py", line 1, in <module>      from .app import app    
File "/srv/tmfapp/app.py", line 12, in <module>      from . import models    
File "/srv/tmfapp/models.py", line 14, in <module>      from flask_sqlalchemy import SQLAlchemy  ModuleNotFoundError: No module named 'flask_sqlalchemy'

所以这很重要:No module named 'flask_sqlalchemy'

文件开头 models.py 当我调用 Flask_SQL :

from flask_sqlalchemy import SQLAlchemy

你能告诉我我做错了什么吗?

提前致谢!

----尝试#01

我尝试在 requierements.txt 的末尾添加这个:

pymysfzefzefql==0.10.0

显然不起作用,但这是我的错误消息:

╔════════════════════════════════════════════════════════════╗
╠═ Uploading 2 files to Google Cloud Storage                ═╣
╚════════════════════════════════════════════════════════════╝
File upload done.
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9] Cloud build 233def4f-8dba-4062-8b61-8d040e5797a4 status: FAILURE
Error ID: f8df99ad
Error type: INTERNAL
Error message: Collecting flask==1.1.2
  Using cached Flask-1.1.2-py2.py3-none-any.whl (94 kB)
Collecting werkzeug==1.0.1
  Using cached Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
Collecting sqlalchemy==1.3.18
  Using cached SQLAlchemy-1.3.18-cp38-cp38-manylinux2010_x86_64.whl (1.3 MB)
Collecting flask_sqlalchemy==2.4.4
  Using cached Flask_SQLAlchemy-2.4.4-py2.py3-none-any.whl (17 kB)
Collecting pymysql==0.10.0
  Using cached PyMySQL-0.10.0-py2.py3-none-any.whl (47 kB)
ERROR: Could not find a version that satisfies the requirement pymysfzefzefql==0.10.0 (from -r requirements.txt (line 6)) (from versions: none)
ERROR: No matching distribution found for pymysfzefzefql==0.10.0 (from -r requirements.txt (line 6))

在报错前我们可以看到依赖好像导入成功了

requirements.txt 试试这个:

Flask-SQLAlchemy==2.4.4