I have been working on a Django project locally and I finally decided to release it to AWS Elastic Beanstalk and during the deployment process I keep receiving an error saying:
from django.core.wsgi import get_wsgi_application
No module named 'django'
I have walked through the official tutorial from AWS as well as the tutorial from the Real Python I have verified that Django is in fact installed by running pip freeze
and it returns
...
colorama==0.3.9
Django==2.2.9
django-celery==3.3.1
....
Also I've been working with Django extensively locally. But just to be sure I ran the following command and got this output.
(.venv) $ source .venv/bin/activate
(.venv) $ pip install django
Requirement already satisfied: django in ./.venv/lib/python3.7/site-packages (2.2.9)
Requirement already satisfied: sqlparse in ./.venv/lib/python3.7/site-packages (from django) (0.3.0)
Requirement already satisfied: pytz in ./.venv/lib/python3.7/site-packages (from django) (2019.3)
And when I run:
(.venv) $ python
Python 3.7.4 (default, Jul 9 2019, 18:13:23)
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print(django.__file__)
.../code/core_web_app/.venv/lib/python3.7/site-packages/django/__init__.py
Sorry if this is over kill but most of the post I have looked at have comments asking if Django is installed or saying that Django must be installed. My presumption is that Django is installed on my local machine but not on my remote. Furthermore, I have noted this post and made sure that my requirements.txt file is in my root directory as well. Below you may find some additional information.
.ebextensions/django.config
option_settings:
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "myapp.settings"
"PYTHONPATH": "/opt/python/current/app/src:$PYTHONPATH"
"aws:elasticbeanstalk:container:python":
WSGIPath: src/myapp/wsgi.py
NumProcesses: 3
NumThreads: 20
"aws:elasticbeanstalk:container:python:staticfiles":
"/static/": "www/static/"
src/myapp/wsgi.py
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myapp.settings')
application = get_wsgi_application()
Any help would greatly be appreciated as this is my first time working with this and I presume I am making a really silly mistake somewhere.