[Django]-Setting up Django on AWS Elastic Beanstalk: WSGIPath not found

14πŸ‘

βœ…

From https://forums.aws.amazon.com/thread.jspa?messageID=396656&#396656

The β€œ.ebextensions” directory must be in the root level directory of your application, but from the log output, the directory is instead in the β€œmysite/.ebextensions” directory. So for example, after following the django tutorial in the docs when you run β€œgit aws.push” your root directory would look like this:

.
β”œβ”€β”€ .ebextensions
β”‚   └── python.config
β”œβ”€β”€ .elasticbeanstalk
β”‚   β”œβ”€β”€ config
β”œβ”€β”€ .git
β”œβ”€β”€ .gitignore
β”œβ”€β”€ manage.py
β”œβ”€β”€ mysite
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ settings.py
β”‚   β”œβ”€β”€ urls.py
β”‚   └── wsgi.py
└── requirements.txt

Instead of this:

.
└── mysite
    β”œβ”€β”€ .ebextensions
    β”œβ”€β”€ .elasticbeanstalk
    β”œβ”€β”€ .git
    β”œβ”€β”€ .gitignore
    β”œβ”€β”€ manage.py
    β”œβ”€β”€ mysite
    └── requirements.txt
πŸ‘€tutuDajuju

8πŸ‘

Find .elasticbeanstalk/optionsettings.your-app-name in your app’s root directory. Search for WSGIPath and make sure it’s the path you intend. It looks like it defaults to application.py.

πŸ‘€Rose Perrone

3πŸ‘

I had the same problem (β€œYour WSGIPath refers to a file that does not exist”), and finally found a solution:

Note: At first, I was searching in the wrong direction, because EB was also showing this message: Error occurred during build: Command 01_migrate failed.. So I though the files, including the *.config, were correctly located.

πŸ‘€Leo

3πŸ‘

Solution: using EBCLI

open eb config
For me it showed WSGIPath: application.py
Now Change it to

WSGIPath: my_app/wsgi.py

save and deploy.

πŸ‘€Arun K

2πŸ‘

Ok, here’s what worked for me after trying a million things. You have to run eb update in order to update the environment.

So make sure .elasticbeanstalk/optionsettings.whatever-env has WSGIPath set to what you want it, and make sure .ebextensions/whatever.config has this:

option_settings:
  - namespace: aws:elasticbeanstalk:container:python
    option_name: WSGIPath
    value: whatever/wsgi.py

Then run eb update and it should work. Remember you have to set the alias to make sure your eb command actually works. For example:

alias eb="python2.7 ../AWS-ElasticBeanstalk-CLI-2.6.3/eb/linux/python2.7/eb"
πŸ‘€capcom

2πŸ‘

I had the same issue after following AWS’s docs to the dot. What I did to avoid it was initialize an application through the EB CLI step by step, without using the command the AWS docs instructed (~/ebdjango$ eb init -p python2.7 django-tutorial), and creating an environment step by step as well. The steps I took in the EB CLI are the following:

  1. Initialize Application
    1. eb init
    2. Select a default region
    3. Enter Application Name (used default by pressing enter)
    4. Confirmed that I am using Python
    5. Selected Python version compatible with my local environment
    6. Set up SSH
  2. Create Environment
    1. eb create
    2. Enter Environment Name (used default by pressing enter)
    3. Enter DNS CNAME prefix (used default by pressing enter)
    4. Select a load balancer type (I selected classic by entering 1)

After Environment is created I use eb config to open EB’s config file to confirm that the path to my WSGI is what it should be:

aws:elasticbeanstalk:container:python:
  NumProcesses: '1'
  NumThreads: '15'
  StaticFiles: /static/=static/
  WSGIPath: path/to/wsgi.py

If any changes are made, make sure you save the file and confirm that everything is squared up by entering eb open in your terminal to open a browser window using the domain name specified in previous steps.

πŸ‘€0xdesdenova

Leave a comment