SQL -Alchemy Module Not Found Ошибка в Google App Engine - PullRequest
0 голосов
/ 05 августа 2020

Я пытаюсь запустить свой первый движок приложений в Google Cloud, но столкнулся с проблемой. Я не нашел ответа в Интернете.

В стандартной среде это мой 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

Подскажите, что я делаю не так?

Заранее спасибо!

---- TRY # 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))

Мы видим до ошибки что зависимости кажутся импортированными успешно.

1 Ответ

2 голосов
/ 05 августа 2020

Попробуйте это в requirements.txt:

Flask-SQLAlchemy==2.4.4
...