Search code examples
pythonflaskpythonanywhere

PythonAnywhere.com Flask web app: no module named 'flask_app'


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?


Solution

  • 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.