title: Django - WSGI script cannot be loaded as Python module
body: <p>This is a well-known issue it seems but I have spent 8 hours trying to fix the issue without any success.</p>
  <p>I have been running a Django project with Apache2 on this VPS before, this issue occurred when I deployed new code and ran a <code>sudo apt-get update</code>. I now receive an Internal server error when trying to reach the website.</p>
  <p>I am desperate, does anyone have a suggestion of what could have happend?</p>
  <p><strong>What I have installed on my Ubuntu 18.04 VPS</strong></p>
  <pre><code>  - sudo apt-get install python3-pip apache2 libapache2-mod-wsgi-py3 
    - sudo apt-get install mysql-server  
    - sudo mysql_secure_installation 
    - sudo apt install git  
    - pip3 install virtualenv  
    - pip3 install django 
    - sudo apt-get install libmysqlclient-dev  
    - pip3 install mysqlclient
  </code></pre>
  <p><strong>Error log</strong></p>
  <pre><code>[Fri Mar 06 22:47:29.96579 2020] mod_wsgi (pid=4877): Target WSGI script '/var/www/project/project/wsgi.py' cannot be loaded as Python module.
  [Fri Mar 06 22:47:29.965710 2020] mod_wsgi (pid=4877): Exception occurred processing WSGI script '/var/www/project/project/wsgi.py'.
  [Fri Mar 06 22:47:29.965712 2020] mod_wsgi (pid=16955): Target WSGI script '/var/www/project/project/wsgi.py' cannot be loaded as Python module.
  [Fri Mar 06 22:47:29.965917 2020] mod_wsgi (pid=16955): Exception occurred processing WSGI script '/var/www/project/project/wsgi.py'.
  [Fri Mar 06 22:47:29.967013 2020] Traceback (most recent call last):
  [Fri Mar 06 22:47:29.967585 2020] File &quot;/var/www/project/project/wsgi.py&quot;, line 17, in &lt;module&gt;
  [Fri Mar 06 22:47:29.967628 2020] application = get_wsgi_application()
  [Fri Mar 06 22:47:29.967703 2020] File &quot;/usr/local/lib/python3.6/dist-packages/django/core/wsgi.py&quot;, line 12, in get_wsgi_application
  [Fri Mar 06 22:47:29.967737 2020] django.setup(set_prefix=False)
  [Fri Mar 06 22:47:29.967815 2020] File &quot;/usr/local/lib/python3.6/dist-packages/django/__init__.py&quot;, line 19, in setup
  [Fri Mar 06 22:47:29.967854 2020] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  [Fri Mar 06 22:47:29.967934 2020] File &quot;/usr/local/lib/python3.6/dist-packages/django/conf/__init__.py&quot;, line 76, in __getattr__
  [Fri Mar 06 22:47:29.967969 2020] self._setup(name)
  [Fri Mar 06 22:47:29.968036 2020] File &quot;/usr/local/lib/python3.6/dist-packages/django/conf/__init__.py&quot;, line 63, in _setup
  [Fri Mar 06 22:47:29.968068 2020] self._wrapped = Settings(settings_module)
  [Fri Mar 06 22:47:29.968139 2020] File &quot;/usr/local/lib/python3.6/dist-packages/django/conf/__init__.py&quot;, line 142, in __init__
  [Fri Mar 06 22:47:29.968168 2020] mod = importlib.import_module(self.SETTINGS_MODULE)
  [Fri Mar 06 22:47:29.968238 2020] File &quot;/usr/lib/python3.6/importlib/__init__.py&quot;, line 126, in import_module
  [Fri Mar 06 22:47:29.968273 2020] return _bootstrap._gcd_import(name[level:], package, level)
  [Fri Mar 06 22:47:29.968347 2020] File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 994, in _gcd_import
  [Fri Mar 06 22:47:29.968419 2020] File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 971, in _find_and_load
  [Fri Mar 06 22:47:29.968488 2020] File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 941, in _find_and_load_unlocked
  [Fri Mar 06 22:47:29.968553 2020] File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 219, in _call_with_frames_removed
  [Fri Mar 06 22:47:29.968662 2020] File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 994, in _gcd_import
  [Fri Mar 06 22:47:29.968734 2020] File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 971, in _find_and_load
  [Fri Mar 06 22:47:29.968809 2020] File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 953, in _find_and_load_unlocked
  [Fri Mar 06 22:47:29.968934 2020] ModuleNotFoundError: No module named 'project'
  </code></pre>
  <p><strong>My 000-default.conf (Apache2)</strong></p>
  <pre><code> &lt;VirtualHost *:80&gt;
      ServerName MY IP HERE
      DocumentRoot /var/www/project
  
      WSGIDaemonProcess MY IP HERE python-path=/usr/lib/python3.6
      #WSGIDaemonProcess MY IP HERE python-home=/var/www/project python-path=/usr/lib/python3.6 
      WSGIProcessGroup MY IP HERE
      WSGIScriptAlias / /var/www/project/project/wsgi.py
  
      &lt;Directory /var/www/project/myapp&gt;
              AllowOverride all
              Require all granted
              Options FollowSymlinks
      &lt;Files wsgi.py&gt;
      Require all granted
      &lt;/Files&gt;
      &lt;/Directory&gt;
  
      Alias /static/ /var/www/project/myapp/static/
  
      &lt;Directory /var/www/project/myapp/static&gt;
              Require all granted
      &lt;/Directory&gt;
  
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
   &lt;/VirtualHost&gt;
  </code></pre>
  <p><strong>My settings.py</strong></p>
  <pre><code>import os
  
  BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  
  SECRET_KEY = 'myKey'
  
  DEBUG = True
  
  ALLOWED_HOSTS = ['myIP']
  
  INSTALLED_APPS = [
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      'myapp',
      'django.contrib.humanize',
  ]
  
  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 = 'project.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 = 'project.wsgi.application'
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.mysql',
          'NAME': 'test',
          'USER': 'root',
          'PASSWORD': 'pass',
          'HOST': '',
          'PORT': '',
         # 'OPTIONS': {
         # 'read_default_file': '/etc/mysql/my.cnf',
         # }
      }
  }
  
  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',
      },
  ]
  
  LANGUAGE_CODE = 'en-us'
  
  TIME_ZONE = 'CET'
  
  USE_I18N = True
  
  USE_L10N = True
  
  USE_TZ = False
  
  USE_THOUSAND_SEPARATOR = True
  
  STATIC_ROOT = '/static/'
  STATIC_URL = '/static/'
  LOGIN_URL = 'index'
  </code></pre>