Forums

ModuleNotFoundError: No module named 'flask_app'

ModuleNotFoundError: No module named 'flask_app'

I have tried so many ways to fix this. I have watched tutorial videos and followed step by step, asked AI many questions, and looked online and everyone seems to have the same answer for this. I have to change "flask_app" in my WSGI file to the name of my file that contains the Flask application, which in my case is "main" as my file is named main.py.

I have created my virtual environment and installed all my requirements in the Bash console.

Below is my code in my WSGI file:

import sys
path = '/home/llions16/Day-71-Deploy-Blog'
if path not in sys.path:
    sys.path.append(path)

from main import app as application

I have reloaded my webapp many times. I have my "Source Code" set to my project folder "/home/llions16/Day-71-Deploy-Blog" and my "Working Directory" set to "/home/llions16/".

This is my code snippet of my Flask App in my main.py file:

app = Flask(__name__)
app.config['SECRET_KEY'] = os.environ["SECRET_KEY"]

Please help. My brain is going to explode. I cannot for the life of me find out why it still says:

2024-10-08 02:20:04,993: Error running WSGI application 2024-10-08 02:20:04,995: ModuleNotFoundError: No module named 'flask_app' 2024-10-08 02:20:04,995: File "/var/www/llions16_pythonanywhere_com_wsgi.py", line 16, in <module> 2024-10-08 02:20:04,995: from flask_app import app as application # noqa

Not only did I change "flask_app" to "main" in my WSGI file, but there is not 16 lines of code which is where it states the error is being found in the WSGI file. As I've said I have saved this file and reloaded my webapp many times. Please help.

That error is from around 12 hours before you created this post. Make sure that you are reading the most recent error message. Each line in the log has a timestamp.

did you get this figured out? I'm facing that same issue and can't figure it out

We have a help page for debugging import errors here: https://help.pythonanywhere.com/pages/DebuggingImportError/