8👍
I have read the realpython blog post that you referred to. I would also refer you to the AWS tutorial. It is written for the deployment of a bare bones Django project and it can be found at:
I found it useful to work through, and learned a great deal fixing the error you have identified. Of course the fix is related to my own implementation of the tutorial, which I followed step-by-step. I have read other posts that talk to this issue, but the solution stated here was not provided in those posts, as far as I can tell.
An abbreviated version of the tutorial follows to provide some context for the comments made here. This abbreviated version begins after creating/activating the virtual environment, but before its activation.
$ mkdir ed_django_app
$ . venv/Scripts/activate
(venv)[~eb_django_app]$ django-admin startproject django_eb
(venv)[~eb_django_app/django_eb]$ python manage.py migrate
(venv)[~eb_django_app/django_eb]$ python manage.py runserver
(venv)[~eb_django_app]$ pip freeze > requirements.txt
(venv)[~eb_django_app]$ deactivate
[~eb_django_app]$ eb init –region us-east-1
After the “eb init” command the .elasticbeanstalk directory, along with some files, are created in the initialization process. In that directory you will find the config.yml file. Its contents are:
branch-defaults:
default:
environment: eb-django-dev
global:
application_name: eb_django_app
default_ec2_keyname: myec2keyname
default_platform: Python 2.7
default_region: us-east-1
profile: eb-cli
sc: null
The tutorial directs the developer to then create a directory called .ebextensions and create the 01-eb_django.config file:
option_settings:
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "django_eb.settings"
PYTHONPATH: "/opt/python/current/app/django_eb:$PYTHONPATH"
"aws:elasticbeanstalk:container:python":
WSGIPath: "django_eb/django_eb/wsgi.py"
This is YAML and the indentation matters. At least 1 space indent. In this case there are 2 spaces of indent at each level. The WSGIPath is set correctly. It is important to make sure the directory structure is the same as what is indicated in the tutorial.
In the tutorial the “eb create” command is now issued, and as you noted, the following arises:
ERROR: WSGIPath refers to a file that does not exist
The problem that was identified existed in the config.yml where there is the key-pair for application_name:
global:
application_name: eb_django_app
It was changed to:
global:
application_name: django_eb
This resolved the ERROR for me.
12👍
One thing I found when I encountered this error, is that if your repository is a git repository your .ebextensions folder must be tracked and committed otherwise it will not be picked up properly on eb deploy.
- Django: generate download link
- What more do I need to do to have Django's @login_required decorator work?
- Disable caching for a view or url in django
- What is the proper way of testing throttling in DRF?
2👍
Using eb
:
eb config
Go to aws:elasticbeanstalk:container:python:
and change WSGIPath from:
application.py
to
mysite/wsgi.py
With “mysite” being your application name ofcourse
1👍
possible solution error : Your WSGIPath refers to a file that does not exist
after following this tutorial:
https://realpython.com/deploying-a-django-app-to-aws-elastic-beanstalk/
I got the error when I was uploading my protect to aws.
The step that I forgot was to activate my virtual env and from my there type the command ‘eb deploy’
note : this error can also occur in different circumstances
- Making Django Readonly ForeignKey Field in Admin Render as a Link
- Django 2.0 Populating Database with a Script
- Docker compose for production and development
0👍
This in django.config file, say your app name is ‘yourappname’,
worked for me.
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: yourappname.wsgi:application
- How to add attributes to option tags?
- How to assert django uses particular template in pytest
- Django annotate query set with a count on subquery
- Django difference between clear() and delete()