I have my flask app working just great with the dev server when I run it like this:
python manage.py runserver
But when I try to run it with wsgi I get all kinds of "module not installed" errors, and even syntax errors. Strangely, it shows a different error each time I hit an app route.
on some of the errors, from the output in the apache error log, I can see that it's trying to run 2.7 versions of packages, when I am using 3.4.
File "/usr/lib/python2.7/dist-packages/requests/__init__.py", line 55, in <module>
I don't know why this is, python 3 is the default on the server and
$ python --version
Python 3.4.2
is the output for every user on the system. I am using virtualenv, but I did follow these instructions for setting up mod_wsgi with virtualenv: http://flask.pocoo.org/docs/0.11/deploying/mod_wsgi/
my wsgi file looks like this:
import sys
activate_this = '/home/flask-dev/es_app/venv/bin/activate_this.py'
with open(activate_this) as file_:
exec(file_.read(), dict(__file__=activate_this))
print(sys.path)
from searchapp import app as application
and that print(sys.path) outputs this when I run it like 'python run.wsgi':
['/home/flask-dev/es_app/venv/lib/python3.4/site-packages', '/home/flask-dev/es_app', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/usr/lib/python3.4/lib-dynload', '/usr/lib/python3/dist-packages']
i.e. a path to the 2.7 packages is nowhere in sight. Also, all the required modules are installed in my virtualenv, which is why it works fine when I run the dev server.
Totally stumped on this. Any help appreciated.