title: mod_wsgi: ImportError: No module named 'encodings'
body: <p>I'm using Apache 2.2.15 on CentOS 6.5. I'm trying to set up a Django app using mod_wsgi.
  I'm using a virtual environment, and mod_wsgi was configured with <code>--with-python=/path/to/virtualenv/bin/python3.4</code>.</p>
  
  <p>I've added this to my <code>httpd.conf</code>:</p>
  
  <pre><code>WSGIPythonPath /srv/myproject:/path/to/virtualenv/lib/python3.4/site-packages
  WSGIPythonHome /path/to/virtualenv
  &lt;VirtualHost *:80&gt;
  WSGIScriptAlias / /srv/myproject/myproject/wsgi.py
  ...
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>In <code>wsgi.py</code>, I added</p>
  
  <pre><code>sys.path.insert(1, "/path/to/virtualenv/lib/python3.4/site-packages")
  </code></pre>
  
  <p>The problem is that when I try to open the app in my browser, it loads indefinitely. Here's the Apache error log:</p>
  
  <pre><code>Fatal Python error: Py_Initialize: Unable to get the locale encoding
  ImportError: No module named 'encodings'
  [Mon Jun 30 17:37:28 2014] [notice] child pid 19370 exit signal Aborted (6)
  [Mon Jun 30 17:37:28 2014] [notice] child pid 19371 exit signal Aborted (6)
  ...
  [Mon Jun 30 17:37:28 2014] [notice] child pid 19377 exit signal Aborted (6)
  Fatal Python error: Py_Initialize: Unable to get the locale encoding
  ImportError: No module named 'encodings'
  </code></pre>
  
  <p>What's interesting is that in both the system installation of Python (2.6) and the virtual environment version (3.4), <code>import encodings</code> works fine! I've tried using the example WSGI script from <a href="https://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Python_Installation_In_Use">the mod_wsgi CheckingYourInstallation page</a> to confirm which version of Python is being used by Apache, but I get the same ImportError.</p>
  
  <p>Does anyone have a suggestion for next steps? I've scoured the docs but I don't know where to go from here.</p>