Deploying Django to AWS - WSGIPath refers to a file that does not exist
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
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:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html#python-django-configure-for-eb
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.
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.
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