title: Python 3 Django on App Engine Standard: App Fails to Start
body: <p>I'm trying to deploy a Django application on Google App Engine in the Standard Python37 Environment. I've had a version of it running fine in the Flexible environment, but I'm creating a staging version that I want to run in the Standard env.</p>
  
  <p>When I deploy and visit the app I get a 500 error. Looking in the logs I can see some messages about exceptions in worker processes. I get the error:</p>
  
  <blockquote>
    <p>ModuleNotFoundError: No module named 'main'</p>
  </blockquote>
  
  <p>This is the stack trace from the error:</p>
  
  <blockquote>
    <p>Traceback (most recent call last):</p>
    
    <p>File "/env/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
    worker.init_process()</p>
    
    <p>File "/env/lib/python3.7/site-packages/gunicorn/workers/gthread.py", line 104, in init_process
    super(ThreadWorker, self).init_process()</p>
    
    <p>File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
    self.load_wsgi()</p>
    
    <p>File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
    self.wsgi = self.app.wsgi()</p>
    
    <p>File "/env/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()</p>
    
    <p>File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
    return self.load_wsgiapp()</p>
    
    <p>File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
    return util.import_app(self.app_uri)</p>
    
    <p>File "/env/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
    <strong>import</strong>(module)</p>
    
    <p>ModuleNotFoundError: No module named 'main'</p>
  </blockquote>
  
  <p>I haven't modified <code>my_site/wsgi.py</code> since Django created it for me, here it is:</p>
  
  <pre><code>import os
  
  from django.core.wsgi import get_wsgi_application
  
  os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_site.settings")
  
  application = get_wsgi_application()
  </code></pre>
  
  <p>This is my <code>app.yaml</code>:</p>
  
  <pre><code>runtime: python37
  env: standard
  
  beta_settings:
      cloud_sql_instances: project:us-west1:sql-instance
  
  handlers:
  - url: /static
    static_dir: staticfiles/
  - url: .*
    secure: always
    redirect_http_response_code: 301
    script: my_site.wsgi.application
  
  env_variables:
    # vars
  </code></pre>
  
  <p>This matches pretty close with the <code>app.yaml</code> in: <a href="https://cloud.google.com/python/django/appengine" rel="noreferrer">https://cloud.google.com/python/django/appengine</a>.
  I've also tried changing <code>script</code> to <code>auto</code> as shown here: <a href="https://cloud.google.com/appengine/docs/standard/python3/config/appref" rel="noreferrer">https://cloud.google.com/appengine/docs/standard/python3/config/appref</a>, but still get the same error.</p>
  
  <p>I've looked at this question: <a href="https://stackoverflow.com/questions/47836949/django-gunicorn-on-app-engine-error-no-module-named-my-project">Django - gunicorn on App Engine. Error: &#39;No Module Named my_project&#39;</a>, and <code>my_site</code> does have an underscore in it, but isn't camelCased.</p>
  
  <p>I'm not sure what the source of this error is. Any ideas would be much appreciated.</p>