I've got a basic "hello world" Flask app running.
I'm on Ubuntu 14.04, using Apache 2.4. I've installed mod_wsgi.
I've created a ~/web/piFlask/venv/
to hold a virtualenv-created Python2 with flask installed.
However, I wish to have my flaskapp import a Python3.x module I have written.
What do I need to do to make this happen?
I tried creating a ~/web/piFlask/venv3/
and modifying ~/web/piFlask/piFlask.wsgi
:
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
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.
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 ~/web/piFlask/venv/
interpreter to actually process the request.
I think I could persuade mod_wsgi to use either a system Python3 or my own venv3/... by setting WSGIPythonPath /home/pi/web/piFlask/venv3/lib/python3.4/site-packages
in /etc/apache2/mods-available/wsgi.conf
But I found an instruction somewhere saying you have to compile mod_wsgi for Py3, and the bottom quickly falls out to this problem.