Issue
I'm deploying Django in Google App Engine.
I get 502 Bad Gateway and in the log I get the following error:
2021-03-08 12:08:18 default[20210308t130512] Traceback (most recent call last): File "/layers/google.python.pip/pip/lib/python3.9/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker worker.init_process() File "/layers/google.python.pip/pip/lib/python3.9/site-packages/gunicorn/workers/gthread.py", line 92, in init_process super().init_process() File "/layers/google.python.pip/pip/lib/python3.9/site-packages/gunicorn/workers/base.py", line 119, in init_process self.load_wsgi() File "/layers/google.python.pip/pip/lib/python3.9/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi self.wsgi = self.app.wsgi() File "/layers/google.python.pip/pip/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi self.callable = self.load() File "/layers/google.python.pip/pip/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 49, in load return self.load_wsgiapp() File "/layers/google.python.pip/pip/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp return util.import_app(self.app_uri) File "/layers/google.python.pip/pip/lib/python3.9/site-packages/gunicorn/util.py", line 358, in import_app mod = importlib.import_module(module) File "/opt/python3.9/lib/python3.9/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 986, in _find_and_load_unlocked File "", line 680, in _load_unlocked File "", line 790, in exec_module File "", line 228, in _call_with_frames_removed File "/srv/main.py", line 1, in from django_project.wsgi import application File "/srv/django_project/wsgi.py", line 16, in application = get_wsgi_application() File "/layers/google.python.pip/pip/lib/python3.9/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application django.setup(set_prefix=False) File "/layers/google.python.pip/pip/lib/python3.9/site-packages/django/init.py", line 19, in setup configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) File "/layers/google.python.pip/pip/lib/python3.9/site-packages/django/conf/init.py", line 82, in getattr self._setup(name) File "/layers/google.python.pip/pip/lib/python3.9/site-packages/django/conf/init.py", line 69, in _setup self._wrapped = Settings(settings_module) File "/layers/google.python.pip/pip/lib/python3.9/site-packages/django/conf/init.py", line 170, in init mod = importlib.import_module(self.SETTINGS_MODULE) File "/opt/python3.9/lib/python3.9/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/srv/django_project/settings.py", line 84, in import pymysql # noqa: 402 ModuleNotFoundError: No module named 'pymysql'
The problem is that I already installed pymysql
, in fact if I run pip3 install pymysql
, I get Requirement already satisfied: ...
Why is that? Thanks in advance!
Edit:
Here's requirements.txt
:
asgiref==3.3.1
attrs==20.3.0
Automat==20.2.0
certifi==2020.12.5
cffi==1.14.4
chardet==4.0.0
constantly==15.1.0
cryptography==3.4.1
cssselect==1.1.0
Django==3.1.6
django-phonenumber-field==5.0.0
django-widget-tweaks==1.4.8
hyperlink==21.0.0
idna==2.10
incremental==17.5.0
instaloader==4.6.1
itemadapter==0.2.0
itemloaders==1.0.4
jmespath==0.10.0
jsonfield==3.1.0
lxml==4.6.2
parsel==1.6.0
phonenumberslite==8.12.18
progress==1.5
Protego==0.1.16
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.20
PyDispatcher==2.0.5
PyHamcrest==2.0.2
pyOpenSSL==20.0.1
pytz==2021.1
queuelib==1.5.0
requests==2.25.1
schedule==0.6.0
Scrapy==2.4.1
semantic-version==2.8.5
service-identity==18.1.0
setuptools-rust==0.11.6
six==1.15.0
sqlparse==0.4.1
toml==0.10.2
urllib3==1.26.3
w3lib==1.22.0
zope.interface==5.2.0
Solution
If you run pip3 install pymysql
in your local computer, this does not mean that when you deploy the app this module is packaged. In fact GAE attempts to install everything at build time using your requirements.txt
file so it doesn't matter if you installed everything in your PC since GAE will not use what you have in local (talking about packages installed with pip
).
Checking your requirements.txt
file I do not see that the package PyMySQL
is added. You should add it to that file and attempt to deploy again.
Answered By - Ferregina Pelona
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.