title: Getting Flask to use Python3 (Apache/mod_wsgi)
body: <p>I've got a basic "hello world" Flask app running.</p>
  
  <p>I'm on Ubuntu 14.04,  using Apache 2.4.  I've installed mod_wsgi.</p>
  
  <p>I've created a <code>~/web/piFlask/venv/</code> to hold a virtualenv-created Python2 with flask installed.</p>
  
  <p>However, I wish to have my flaskapp import a Python3.x module I have written.</p>
  
  <p>What do I need to do to make this happen?</p>
  
  <p>I tried creating a <code>~/web/piFlask/venv3/</code> and modifying <code>~/web/piFlask/piFlask.wsgi</code>:</p>
  
  <pre><code>import os, sys
  
  PROJECT_DIR = '/home/pi/web/piFlask'
  
  activate_this = os.path.join(PROJECT_DIR, 'venv3/bin', 'activate_this.py')
  execfile(activate_this, dict(__file__=activate_this))
  sys.path.insert(0, PROJECT_DIR)
  
  from piFlask import app as application
  
  application.debug = True
  </code></pre>
  
  <p>But I don't think this is sufficient. This .wsgi is in fact a Python file that will get executed by mod_wsgi, which I'm sure will use a Py2.x interpreter to do the execution.</p>
  
  <p>So if I'm understanding correctly, mod_wsgi fires up the system Python in order to execute this .wsgi, which will in turn fire up my <code>~/web/piFlask/venv/</code> interpreter to actually process the request.</p>
  
  <p>I think I could persuade mod_wsgi to use either a system Python3 or my own venv3/... by setting <code>WSGIPythonPath /home/pi/web/piFlask/venv3/lib/python3.4/site-packages</code> in /etc/apache2/mods-available/wsgi.conf</p>
  
  <p>But I found an instruction somewhere saying you have to compile mod_wsgi for Py3, and the bottom quickly falls out to this problem.</p>