Forums

I have a problem with the WSGI file finding the python file

i keep getting the error "Something went wrong while trying to load this website;" and when I get in the log file its full with errors like this:

2023-02-16 14:07:14,848: Error running WSGI application

2023-02-16 14:07:14,849: ModuleNotFoundError: No module named 'flask_app'

2023-02-16 14:07:14,849:   File "/var/www/rohihilel_pythonanywhere_com_wsgi.py", line 16, in <module>

2023-02-16 14:07:14,849:     from flask_app import app as application  # noqa

2023-02-16 14:07:14,849: ***************************************************

2023-02-16 14:07:14,849: If you're seeing an import error and don't know why,

2023-02-16 14:07:14,849: we have a dedicated help page to help you debug:

2023-02-16 14:07:14,849: https://help.pythonanywhere.com/pages/DebuggingImportError/

2023-02-16 14:07:14,849: ***************************************************

I spent days trying to find the solution so I need your help. this is the WSGI file:

import sys

#add your project directory to the sys.path
project_home = u'/home/rohihilel/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 api_cgpt import app as application  # noqa

and yes, I have the python file named api_cgpt.py that has the flask app in this directory.

really need your help.thank you

Did you reload the web app after changing the WSGI file? The error you're showing doesn't match what is in the file, as you pasted it.