Forums

WSGI is unable to find flask_app

I have my flask_app.py located at mysite/flask_app.py, but when I try to run my web app I get an ImportError saying:

ImportError: No module named 'flask_app'
2017-01-18 06:24:31,417 :  File "/var/www/jss367_pythonanywhere_com_wsgi.py", line 16, in <module>

I ran the wsgi file directly and it opens a python console as I expected. Then I tried to import flask_app and it works exactly as expected as well. But I've tried running the web app over and over and get the same error. I even deleted flask_app.py and reset it to the most basic components. Is ther anything else I should try?

Make sure that the directory where flask_app is stored is being added to the path in your wsgi file.

It appears to be. The wsgi has:

add your project directory to the sys.path

project_home = u'/home/jss367/mysite' if project_home not in sys.path: sys.path = [project_home] + sys.path

import flask app but need to call it "application" for WSGI to work

from flask_app import app as application

flask_app is at /home/jss367/mysite/flask_app.py, so I think it should see it.

I just booted up a new bash console after letting it sit for a few hours and it's giving me the "Hello from Flask!" page. I've done the entire flask/mysql tutorial and added more templates, all of which are in my files, but it's just giving me the basic flask app response. I don't even have "Hello from Flask!" in my file anymore.

Have you reloaded the web app?

Many many times. I ended up reverting some git commits and removing code until it worked again.