1

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?

1
  • 3
    Can you show us what your directory structure looks like, the command you're using to start the server, and the location from which you're running that command? Commented Jul 24, 2018 at 13:07

2 Answers 2

10

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.

Sign up to request clarification or add additional context in comments.

1 Comment

That was the issue indeed :) my Flask app was called web-app.py... Didn't realize I had to change it. Thanks a lot!
3

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 ?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.