AttributeError: 'module' object has no attribute 'application'. What should I be calling it instead?

I am getting this error on my app's error logs:

Traceback (most recent call last):
2015-01-15 03:49:28,407 :  File "/bin/", line 130, in __call__
2015-01-15 03:49:28,408 :    self.error_log_file.logger.exception("Error running WSGI application")
2015-01-15 03:49:28,408 :  File "/usr/lib/python2.7/logging/", line 1185, in exception
2015-01-15 03:49:28,408 :    self.error(msg, *args, **kwargs)
2015-01-15 03:49:28,408 :  File "/usr/lib/python2.7/logging/", line 1178, in error
2015-01-15 03:49:28,408 :    self._log(ERROR, msg, args, **kwargs)
2015-01-15 03:49:28,408 :  File "/usr/lib/python2.7/logging/", line 1270, in _log
2015-01-15 03:49:28,409 :    record = self.makeRecord(, level, fn, lno, msg, args, exc_info, func, extra)
2015-01-15 03:49:28,409 :  File "/usr/lib/python2.7/logging/", line 1244, in makeRecord
2015-01-15 03:49:28,409 :    rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
2015-01-15 03:49:28,409 :  File "/usr/lib/python2.7/logging/", line 284, in __init__
2015-01-15 03:49:28,409 :    self.threadName = threading.current_thread().name
2015-01-15 03:49:28,409 :  File "/usr/lib/python2.7/", line 1160, in currentThread
2015-01-15 03:49:28,410 :    return _active[_get_ident()]
2015-01-15 03:49:28,410 :  File "/bin/", line 122, in __call__
2015-01-15 03:49:28,410 :    app_iterator =, start_response)
2015-01-15 03:49:28,410 :  File "/bin/", line 136, in import_error_application
2015-01-15 03:49:28,410 :    raise e
2015-01-15 03:49:28,410 :AttributeError: 'module' object has no attribute 'application'

I started a flask app and it generated from flask_app import app as application in my config file. But maybe its not importing correctly? In my app I use app = Flask(name), but was under the impression that I could use anything? not just "application"

In the WSGI file, you need to define a variable called application, and you can set that to the variable that you define in your Flask app. So you can have any name you want in your Flask code, but if it's not app, you need to change the line in the WSGI file so that PythonAnywhere knows what you chose.

i don't understand. So in my WSGI file, I already have from flask_app import app as application . Doesn't that take care of defining the application variable as app for use in my server code?

Do I need to add application = Flask(__name__) into the WSGI file? And take that out of my server file?

Did you manage to figure this out? Your site seems to be up and running now...

PS -- for anyone else struggling with import errors and sys.path issues, check out

getting django error module 'user_username_wgi' has no attribute application'

So how can I solve it?

You need the variable "application" to exist in your wsgi file and be set equal to the app that you're like to publish. See the examples in the default wsgi file.