title: Django - ImportError : no module named django.core.wsgi
body: <p>I am trying to deploy my Django application with Apache and mod_wsgi.</p>
  
  <p>I installed and configured them according to following references:-
  <a href="https://modwsgi.readthedocs.io/en/develop/user-guides/quick-installation-guide.html" rel="nofollow noreferrer">https://modwsgi.readthedocs.io/en/develop/user-guides/quick-installation-guide.html</a></p>
  
  <p><a href="https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/modwsgi/" rel="nofollow noreferrer">https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/modwsgi/</a></p>
  
  <p>My django project tree - /home/zahlen</p>
  
  <pre><code> mysite
  ├── db.sqlite3
  ├── log
  │   ├── access.log
  │   └── error.log
  ├── manage.py
  ├── mysite
  │   ├── __init__.py
  │   ├── settings.py
  │   ├── static
  │   ├── templates
  │   ├── urls.py
  │   ├── views.py
  │   ├── wsgi.py
  ├── places
  │   ├── admin.py
  │   ├── apps.py
  │   ├── __init__.py
  │   ├── migrations
  │   ├── models.py
  │   ├── static
  │   ├── templates
  │   ├── tests.py
  │   ├── urls.py
  │   ├── views.py
  └── static
  </code></pre>
  
  <p>django is present in <code>/home/zahlen/.local/lib/site-packages</code></p>
  
  <p>//apache2/apache2.conf</p>
  
  <pre><code>....
  ....
  LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
  WSGIPythonPath /home/zahlen/mysite:/home/zahlen/.local/lib/python2.7/site-packages
  &lt;Directory /home/zahlen/mysite/mysite&gt;
      &lt;Files wsgi.py&gt;
          Require all granted
      &lt;/Files&gt;
  &lt;/Directory&gt;
  </code></pre>
  
  <p>//apache2/sites-available/000-default.conf  VirtualHost Configuration</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      ServerName www.mysite.com
      ServerAlias mysite.com
      ServerAdmin webmaster@mysite.com
      Alias /static /home/zahlen/mysite/mysite
      &lt;Directory /home/zahlen/mysite/static&gt;
          Require all granted
      &lt;/Directory&gt;
      ErrorLog /home/zahlen/mysite/log/error.log
      CustomLog /home/zahlen/mysite/log/access.log combined
  
      &lt;Directory /home/zahlen/mysite/mysite/&gt;
          &lt;Files wsgi.py&gt;
              Require all granted
          &lt;/Files&gt;
      &lt;/Directory&gt;
  
      WSGIDaemonProcess mysite.com python-path=/home/zahlen/mysite
      WSGIProcessGroup mysite.com
      WSGIScriptAlias / /home/zahlen/mysite/mysite/wsgi.py
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>Django and mod_wsgi are configured to use <strong>python2.7</strong>
   . Vitualenv is <strong>not</strong> used and 
  Apache uses the <strong>Event MPM</strong></p>
  
  <p>All of this is on a Ubuntu Server Virtual Machine.</p>
  
  <p>//log/apache2/error.log gives the following line which verifies use of python2.7</p>
  
  <pre><code>....
  [Sat Feb 17 02:16:45.475182 2018] [mpm_event:notice] [pid 7282:tid 140680615626624] AH00489: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
  ....
  </code></pre>
  
  <p>/home/zahlen/mysite/mysite/wsgi.py</p>
  
  <pre><code>import os,sys
  sys.path.append('/home/zahlen/mysite')
  sys.path.append('/home/zahlen/mysite/mysite')
  sys.path.append('/home/zahlen/.local/lib/python2.7/site-packages')
  from django.core.wsgi import get_wsgi_application
  os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
  
  application = get_wsgi_application()
  </code></pre>
  
  <p>My browser throws Internal Server Error on the host machine every time i open my site using ip address of the VM</p>
  
  <p>//mysite/log/error.log</p>
  
  <pre><code>[Sat Feb 17 02:13:55.862423 2018] [wsgi:error] [pid 7152:tid 139643385603840] [remote 192.168.56.1:46153] mod_wsgi (pid=7152): Target WSGI script '/home/zahlen/mysite/mysite/wsgi.py' cannot be loaded as Python module.
  [Sat Feb 17 02:13:55.862536 2018] [wsgi:error] [pid 7152:tid 139643385603840] [remote 192.168.56.1:46153] mod_wsgi (pid=7152): Exception occurred processing WSGI script '/home/zahlen/mysite/mysite/wsgi.py'.
  [Sat Feb 17 02:13:55.862579 2018] [wsgi:error] [pid 7152:tid 139643385603840] [remote 192.168.56.1:46153] Traceback (most recent call last):
  [Sat Feb 17 02:13:55.862619 2018] [wsgi:error] [pid 7152:tid 139643385603840] [remote 192.168.56.1:46153]   File "/home/zahlen/mysite/mysite/wsgi.py", line 12, in &lt;module&gt;
  [Sat Feb 17 02:13:55.862743 2018] [wsgi:error] [pid 7152:tid 139643385603840] [remote 192.168.56.1:46153]     from django.core.wsgi import get_wsgi_application
  [Sat Feb 17 02:13:55.862781 2018] [wsgi:error] [pid 7152:tid 139643385603840] [remote 192.168.56.1:46153] ImportError: No module named django.core.wsgi
  </code></pre>
  
  <p>It seems that wsgi.py couldn't import the django package but it is present in <code>/home/zahlen/.local/lib/site-packages/python2.7</code> directory</p>
  
  <p>Can anyone light me the issue please?</p>