Tomy137
Tomy137

Reputation: 111

SQL-Alchemy Module Not Found Error on Google App Engine

I'm trying to make work my first App Engine on Google Cloud but I'm facing a problem. I have not found any response on the web.

On standard environment, this is my 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

This is my requirements.txt :

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

The error message :

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'

So this is important: No module named 'flask_sqlalchemy'

The beginning of the file models.py when I call Flask_SQL :

from flask_sqlalchemy import SQLAlchemy

Can you tell me what I'm doing wrong ?

Thanks in advance!

---- TRY #01

I try to add this at the end of my requierements.txt :

pymysfzefzefql==0.10.0

Obsviously don't work but this is my error message :

╔════════════════════════════════════════════════════════════╗
╠═ 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))

We can see before the error that the dependencies seems to be succeeded imported.

Upvotes: 0

Views: 367

Answers (1)

GAEfan
GAEfan

Reputation: 11360

Try this in requirements.txt:

Flask-SQLAlchemy==2.4.4

Upvotes: 2

Related Questions