title: ModuleNotFoundError - No module named 'main' when attempting to start service
body: <p>Context:</p>
  
  <ul>
  <li>I created a Django application using Python 3.7.</li>
  <li>I am (attempting) to use the 2nd generation Google App Engine standard environment.</li>
  </ul>
  
  <p>My application performs flawlessly when I run it via <code>python manage.py runserver</code>. Yet it comes to a sudden halt when I attempt to deploy it to Google App Engine.</p>
  
  <pre><code>Traceback (most recent call last):
    File "/tmp/tmphgUsp3/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
      worker.init_process()
    File "/tmp/tmphgUsp3/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
      self.load_wsgi()
    File "/tmp/tmphgUsp3/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
      self.wsgi = self.app.wsgi()
    File "/tmp/tmphgUsp3/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
      self.callable = self.load()
    File "/tmp/tmphgUsp3/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
      return self.load_wsgiapp()
    File "/tmp/tmphgUsp3/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
      return util.import_app(self.app_uri)
    File "/tmp/tmphgUsp3/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
      __import__(module)
  ModuleNotFoundError: No module named 'main'
  </code></pre>
  
  <p>I've gone through numerous threads and I cannot find the problem. (For reference the <code>dev_appserver.py</code> emulator produces the same problem, which is a good thing).</p>
  
  <p>Following is my <code>app.yaml</code></p>
  
  <pre><code>runtime: python37
  env: standard
  
  handlers:
  - url: /static
    static_dir: static/
  - url: .*
    script: demosite.wsgi.main
  </code></pre>
  
  <p>My <code>wsgi.py</code> file is located in the following path: <code>demosite/wsgi.py</code> and it's contents look like this:</p>
  
  <pre><code>import os
  
  from django.core.wsgi import get_wsgi_application
  
  os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'demosite.settings')
  
  main = get_wsgi_application()
  </code></pre>
  
  <p>My <code>settings.py</code> file:</p>
  
  <pre><code>import os
  
  class AppSettings(object):
      GoogleCloudProject = os.getenv('GOOGLE_CLOUD_PROJECT')
  
  BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  
  SECRET_KEY = 'say what?'
  
  DEBUG = True
  
  ALLOWED_HOSTS = [
      '*'
  ]
  
  
  INSTALLED_APPS = [
      'anchor.apps.AnchorConfig',
      'crispy_forms',
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
  ]
  
  MIDDLEWARE = [
      'django.middleware.security.SecurityMiddleware',
      'django.contrib.sessions.middleware.SessionMiddleware',
      'django.middleware.common.CommonMiddleware',
      'django.middleware.csrf.CsrfViewMiddleware',
      'django.contrib.auth.middleware.AuthenticationMiddleware',
      'django.contrib.messages.middleware.MessageMiddleware',
      'django.middleware.clickjacking.XFrameOptionsMiddleware',
  ]
  
  ROOT_URLCONF = 'demosite.urls'
  
  TEMPLATES = [
      {
          'BACKEND': 'django.template.backends.django.DjangoTemplates',
          'DIRS': [],
          'APP_DIRS': True,
          'OPTIONS': {
              'context_processors': [
                  'django.template.context_processors.debug',
                  'django.template.context_processors.request',
                  'django.contrib.auth.context_processors.auth',
                  'django.contrib.messages.context_processors.messages',
              ],
          },
      },
  ]
  
  WSGI_APPLICATION = 'demosite.wsgi.main'
  
  try:
      import MySQLdb
  except ImportError:
      import pymysql
      pymysql.install_as_MySQLdb()
  
  
  if os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine'):
      DATABASES = {
          'default': {
              'ENGINE': 'django.db.backends.mysql',
              'NAME': 'webapp',
              'USER': 'aasdeytst',
              'PASSWORD': 'asdasygetasfasdfasd.',
              'HOST': 'asdgiuasfivaasd',
              'PORT': '3306'
          }
      }
  else:
      DATABASES = {
          'default': {
              'ENGINE': 'django.db.backends.mysql',
              'NAME': 'webapp',
              'USER': 'awthdsfhfdhdf',
              'PASSWORD': 'asdasdasdagwdatwt',
              'HOST': 'localhost',
              'PORT': '3306'
          }
      }
  
  AUTH_PASSWORD_VALIDATORS = [
      {
          'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
      },
  ]
  
  ANGUAGE_CODE = 'en-us'
  
  TIME_ZONE = 'UTC'
  
  USE_I18N = True
  
  USE_L10N = True
  
  USE_TZ = True
  
  STATIC_ROOT = 'static'
  STATIC_URL = '/static/'
  
  CRISPY_TEMPLATE_PACK = 'bootstrap4'
  
  LOGIN_REDIRECT_URL = 'index'
  LOGIN_URL = 'login'
  
  SESSION_EXPIRE_AT_BROWSER_CLOSE = False
  SESSION_COOKIE_AGE = 1800
  </code></pre>
  
  <p>What am I missing, what am I doing wrong? I've spent close on 4 hours trying to figure this problem out to no avail.</p>