0

I am trying for two days to deploy my django project on aws. But i am getting one error after another. After lots of searching for answers. This is the last error that i am not able to overcome.

I am following these guides:

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html https://www.1strategy.com/blog/2017/05/23/tutorial-django-elastic-beanstalk/

After all of it. When i try to access my site.It shows 500 Server Error. In Logs it Shows

 Target WSGI script '/opt/python/current/app/github/wsgi.py' cannot be loaded as Python module.

Another question on net answered to comment the Database lines in settings file.

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.sqlite3',
    'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}

This is my wsgi.py file

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')

application = get_wsgi_application()

After it my site loads. But then the problem is there is not database. So it throws another error

settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

So now i am struck here. I have looked at every related question tried there solution but nothing is working. It is my first time trying AWS and it is turning out to be very hard. I deployed my project on heroku successfully but heroku does not support cron job and i really need something like cron job for my project.

This is my django.config in .ebextensions folder

    option_settings:
  "aws:elasticbeanstalk:application:environment":
    DJANGO_SETTINGS_MODULE: "github.settings"
    PYTHONPATH: "$PYTHONPATH"
  "aws:elasticbeanstalk:container:python":
    WSGIPath: "github/wsgi.py"
    StaticFiles: "/static/=www/static/"

packages:
  yum:
    postgresql95-devel: []

After changing to WSGIPath: github.wsgi:application

The error stays the same as 500 internal error but error in log changes so.


[Fri Sep 18 19:50:46.625700 2020] [:error] [pid 6504] [remote 127.0.0.1:0]     application = get_wsgi_application()
[Fri Sep 18 19:50:46.625707 2020] [:error] [pid 6504] [remote 127.0.0.1:0]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Fri Sep 18 19:50:46.625711 2020] [:error] [pid 6504] [remote 127.0.0.1:0]     django.setup(set_prefix=False)
[Fri Sep 18 19:50:46.625721 2020] [:error] [pid 6504] [remote 127.0.0.1:0]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
[Fri Sep 18 19:50:46.625725 2020] [:error] [pid 6504] [remote 127.0.0.1:0]     apps.populate(settings.INSTALLED_APPS)
[Fri Sep 18 19:50:46.625730 2020] [:error] [pid 6504] [remote 127.0.0.1:0]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/apps/registry.py", line 114, in populate
[Fri Sep 18 19:50:46.625734 2020] [:error] [pid 6504] [remote 127.0.0.1:0]     app_config.import_models()
[Fri Sep 18 19:50:46.625740 2020] [:error] [pid 6504] [remote 127.0.0.1:0]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/apps/config.py", line 211, in import_models
[Fri Sep 18 19:50:46.625743 2020] [:error] [pid 6504] [remote 127.0.0.1:0]     self.models_module = import_module(models_module_name)
[Fri Sep 18 19:50:46.625749 2020] [:error] [pid 6504] [remote 127.0.0.1:0]   File "/opt/python/run/venv/lib64/python3.6/importlib/__init__.py", line 126, in import_module
[Fri Sep 18 19:50:46.625753 2020] [:error] [pid 6504] [remote 127.0.0.1:0]     return _bootstrap._gcd_import(name[level:], package, level)
[Fri Sep 18 19:50:46.625758 2020] [:error] [pid 6504] [remote 127.0.0.1:0]   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
[Fri Sep 18 19:50:46.625776 2020] [:error] [pid 6504] [remote 127.0.0.1:0]   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
[Fri Sep 18 19:50:46.625782 2020] [:error] [pid 6504] [remote 127.0.0.1:0]   File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
665, in _load_unlocked
[Fri Sep 18 19:50:46.625816 2020] [:error] [pid 6504] [remote 127.0.0.1:0]     class AbstractBaseUser(models.Model):
[Fri Sep 18 19:50:46.625832 2020] [:error] [pid 6504] [remote 127.0.0.1:0]     value.contribute_to_class(cls, name)
[Fri Sep 18 19:50:46.625838 2020] [:error] [pid 6504] [remote 127.0.0.1:0]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/db/models/options.py", line 206, in contribute_to_class-- More  --[Fri Sep 18 19:50:46.625859 2020] [:error] [pid 6504] [remote 127.0.0.1:0]     backend = load_backend(db['ENGINE'])
[Fri Sep 18 19:50:46.625884 2020] [:error] [pid 6504] [remote 127.0.0.1:0]     check_sqlite_version()
[Fri Sep 18 19:50:46.625889 2020] [:error] [pid 6504] [remote 127.0.0.1:0]   File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 67, in check_sqlite_version-- M[Fri Sep 18 19:50:47.629796 2020] [:error] [pid 6504] [remote 127.0.0.1:28] Traceback (most recent call last):
[Fri Sep 18 19:50:47.629840 2020] [:error] [pid 6504] [remote 127.0.0.1:28]     application = get_wsgi_application()
[Fri Sep 18 19:50:47.629850 2020] [:error] [pid 6504] [remote 127.0.0.1:28]     django.setup(set_prefix=False)
[Fri Sep 18 19:50:47.629860 2020] [:error] [pid 6504] [remote 127.0.0.1:28]     apps.populate(settings.INSTALLED_APPS)
[Fri Sep 18 19:50:47.629884 2020] [:error] [pid 6504] [remote 127.0.0.1:28] RuntimeError: populate() isn't reentrant
[Fri Sep 18 19:50:48.633315 2020] [:error] [pid 6504] [remote 127.0.0.1:28] Traceback (most recent call last):
[Fri Sep 18 19:50:48.633351 2020] [:error] [pid 6504] [remote 127.0.0.1:28]     application = get_wsgi_application()
[Fri Sep 18 19:50:48.633362 2020] [:error] [pid 6504] [remote 127.0.0.1:28]     django.setup(set_prefix=False)
[Fri Sep 18 19:50:48.633372 2020] [:error] [pid 6504] [remote 127.0.0.1:28]     apps.populate(settings.INSTALLED_APPS)
[Fri Sep 18 19:50:48.633396 2020] [:error] [pid 6504] [remote 127.0.0.1:28] RuntimeError: populate() isn't reentrant
[Fri Sep 18 19:50:49.638585 2020] [:error] [pid 6504] [remote 127.0.0.1:32] Traceback (most recent call last):
[Fri Sep 18 19:50:49.638628 2020] [:error] [pid 6504] [remote 127.0.0.1:32]     application = get_wsgi_application()
[Fri Sep 18 19:50:49.638638 2020] [:error] [pid 6504] [remote 127.0.0.1:32]     django.setup(set_prefix=False)
[Fri Sep 18 19:50:49.638647 2020] [:error] [pid 6504] [remote 127.0.0.1:32]     apps.populate(settings.INSTALLED_APPS)
[Fri Sep 18 19:50:49.638672 2020] [:error] [pid 6504] [remote 127.0.0.1:32] RuntimeError: populate() isn't reentrant
[Fri Sep 18 19:51:21.223059 2020] [:error] [pid 6504] [remote 172.31.2.91:32] Traceback (most recent call last):
[Fri Sep 18 19:51:21.223107 2020] [:error] [pid 6504] [remote 172.31.2.91:32]     application = get_wsgi_application()
[Fri Sep 18 19:51:21.223118 2020] [:error] [pid 6504] [remote 172.31.2.91:32]     django.setup(set_prefix=False)
[Fri Sep 18 19:51:21.223154 2020] [:error] [pid 6504] [remote 172.31.2.91:32] RuntimeError: populate() isn't reentrant
[Fri Sep 18 19:51:22.482909 2020] [:error] [pid 6504] [remote 172.31.2.91:32] Traceback (most recent call last):
[Fri Sep 18 19:51:22.482955 2020] [:error] [pid 6504] [remote 172.31.2.91:32]     application = get_wsgi_application()
[Fri Sep 18 19:51:22.482966 2020] [:error] [pid 6504] [remote 172.31.2.91:32]     django.setup(set_prefix=False)
[Fri Sep 18 19:51:22.483001 2020] [:error] [pid 6504] [remote 172.31.2.91:32] RuntimeError: populate() isn't reentrant
shivkhaira
  • 56
  • 1
  • 8

0 Answers0