Reputation: 745
I am new to Python Anywhere and I'm trying to set up a Flask web app I have already built. I followed this tutorial: https://help.pythonanywhere.com/pages/Flask/
But when I try to access the site the log says this:
Error running WSGI application
2018-07-24 11:25:47,696: ModuleNotFoundError: No module named 'flask_app'
2018-07-24 11:25:47,697: File "/var/www/vdvaxel_pythonanywhere_com_wsgi.py", line 111, in <module>
2018-07-24 11:25:47,697: from flask_app import app as application # noqa
I followed the tutorial step by step but still it doesn't work. Can someone explain me what is wrong?
Upvotes: 1
Views: 7431
Reputation: 71451
You need to replace flask_app
with the name of the file containing app
and the app structure (routes, etc). Navigate to:
https://www.pythonanywhere.com/user/{your_username}/files/var/www/vdvaxel_pythonanywhere_com_wsgi.py
Then, on the last line of the file, which is currently from flask_app import app as application
, replace flask_app
with the filename of your current app:
from my_new_web_app import app as application
Also, ensure that project_home
in the wsgi
file is pointing to the folder that stores your flask app file, along with any other folders such as templates
, static
, etc. To find the proper path, navigate to the folder itself and copy the "breadcrumb" navigation, just below the pythonanywhere
logo.
Then save the file and access your site again.
Upvotes: 10
Reputation: 360
It's difficult to answer without the details of your code structure.
1) Is your Flask web app in a file called flask_app.py
?
2) Have you uncommented and updated the block of code from section Configuring the WSGI file:
import sys
path = '/home/yourusername/mysite'
if path not in sys.path:
sys.path.append(path)
so the path
variable value really is the path were the flask_app.py
file is located ?
Upvotes: 3