title: ImportError with Django mod_wsgi
body: <p>I want to move a Django project from test server to Apache (version 2.2.15 on CentOS). I installed mod_wsgi using [1] and am trying to mount my project as a wsgi application using [2].</p>
  
  <p>I followed the Hello World example (helpful SO thread [3]) by putting the test wsgi.py file in the same directory as my existing Django project file (wsgi.py). This works (e.g., I can access via wget).</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
     DocumentRoot &lt;abs_path&gt;/myproject/myproject
     WSGIScriptAlias /wsgi  &lt;abs_path&gt;/myproject/myproject/test_wsgi.wsgi
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <hr>
  
  <p>With this in place, I made a modification to the Apache config file to point to my Django project wsgi file (below) based upon the mod_wsgi and Django documentation [2,4].</p>
  
  <pre><code>WSGIPythonPath &lt;abs_path&gt;/myproject/myproject
  
  &lt;VirtualHost *:80&gt;
  
     DocumentRoot &lt;abs_path&gt;/myproject/myproject
     WSGIScriptAlias /django  &lt;abs_path&gt;/myproject/myproject/wsgi.py
  
     &lt;Directory &lt;abs_path&gt;/myproject/myproject&gt;
              &lt;Files wsgi.py&gt;
                      # Require all granted
                      Order deny,allow
                      Allow from all
              &lt;/Files&gt;
      &lt;/Directory&gt;
  
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>This throws an "500 Internal Server Error:" <strong>"ImportError: No module named django.core.wsgi"</strong></p>
  
  <hr>
  
  <p>mod_wsgi is compiled against Python 2.7, which has Django installed [5].</p>
  
  <pre><code>ldd mod_wsgi.so 
  linux-vdso.so.1 =&gt;  (0x00007fff3ed30000)
  libpython2.7.so.1.0 =&gt; /usr/local/lib/libpython2.7.so.1.0 (0x00007f641e11d000)
  libpthread.so.0 =&gt; /lib64/libpthread.so.0 (0x00007f641dee8000)
  libdl.so.2 =&gt; /lib64/libdl.so.2 (0x00007f641dce4000)
  libutil.so.1 =&gt; /lib64/libutil.so.1 (0x00007f641dae1000)
  libm.so.6 =&gt; /lib64/libm.so.6 (0x00007f641d85c000)
  libc.so.6 =&gt; /lib64/libc.so.6 (0x00007f641d4c9000)
  /lib64/ld-linux-x86-64.so.2 (0x0000003c14e00000)
  </code></pre>
  
  <hr>
  
  <p>Based upon [6], I added path to python2.7 site packages in wsgi.py:</p>
  
  <pre><code># add the myproject project path into the sys.path
  sys.path.append('&lt;PATH_TO_MY_DJANGO_PROJECT&gt;/myproject')
  # add the python2.7 site-packages path to the sys.path
  sys.path.append('&lt;PATH_TO_python2.7&gt;/Lib/site-packages')
  </code></pre>
  
  <p>I also added path to python2.7 in httpd.conf:</p>
  
  <pre><code>WSGIPythonPath &lt;PATH_TO_PROJECT&gt;:&lt;PATH_TO_python2.7&gt;/Lib/site-packages
  </code></pre>
  
  <hr>
  
  <p>Still, I get "500 Internal Server Error:" <strong>"ImportError: No module named django.core.wsgi"</strong>. </p>
  
  <p>Any advice?</p>
  
  <hr>
  
  <p>[1] <a href="http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide" rel="nofollow noreferrer">http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide</a></p>
  
  <p>[2] <a href="http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide" rel="nofollow noreferrer">http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide</a></p>
  
  <p>[3] <a href="https://stackoverflow.com/questions/12173971/hello-world-in-mod-wsgi">Hello World in mod_wsgi</a></p>
  
  <p>[4] <a href="https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/" rel="nofollow noreferrer">https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/</a></p>
  
  <p>[5] <a href="https://stackoverflow.com/questions/8660896/mod-wsgi-isnt-honoring-wsgipythonhome">mod_wsgi isn&#39;t honoring WSGIPythonHome</a></p>
  
  <p>[6] <a href="https://stackoverflow.com/questions/14927345/importerror-no-module-named-django-core-wsgi-apache-virtualenv-aws-wsgi">ImportError: No module named django.core.wsgi Apache + VirtualEnv + AWS + WSGI</a></p>