Forums

When deploying my flask appI get errors like "Error running WSGI application"

This is my WSGI file:

# This file contains the WSGI configuration required to serve up your
# web application at http://<your-username>.pythonanywhere.com/
# It works by setting the variable 'application' to a WSGI handler of some
# description.
#
# The below has been auto-generated for your Flask project

import sys

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

This is part of the error log:

2022-04-20 11:13:01,611: Error running WSGI application
2022-04-20 11:13:01,611: ModuleNotFoundError: No module named 'flask_app'
2022-04-20 11:13:01,612:   File "/var/www/abdulmonem_pythonanywhere_com_wsgi.py", line 16, in <module>
2022-04-20 11:13:01,612:     from flask_app import app as application  # noqa
2022-04-20 11:13:01,612: ***************************************************
2022-04-20 11:13:01,612: If you're seeing an import error and don't know why,
2022-04-20 11:13:01,612: we have a dedicated help page to help you debug: 
2022-04-20 11:13:01,612: https://help.pythonanywhere.com/pages/DebuggingImportError/
2022-04-20 11:13:01,613: ***************************************************
2022-04-20 11:26:04,967: Error running WSGI application
2022-04-20 11:26:04,976: ImportError: cannot import name 'app' from 'application' (/home/abdulmonem/mysite/application.py)
2022-04-20 11:26:04,976:   File "/var/www/abdulmonem_pythonanywhere_com_wsgi.py", line 16, in <module>
2022-04-20 11:26:04,976:     from application import app as application  # noqa

The error in the WSGI configuration file says:

app.application imported but not used

Any help is appreciated, please?

Have you tried looking at https://help.pythonanywhere.com/pages/DebuggingImportError/?

Yes, I tried but couldn't reach a solution.

When I try to install opencv module, it says Disk Quota, does this mean disk space isn't enough?

Yes it does.

Your previous problem is that you do not have a variable in the /home/abdulmonem/mysite/application.py file called app. Import the variable from that file that represents the app.

I think 1 gigabyte will be enough for my project, how to increase the disk space to 1 gigabyte?

You can upgrade your account from your Account page.