PythonAnywhere Forums

Error running WSGI application

2016-07-27 02:38:54,358 :Error running WSGI application Traceback (most recent call last): File "/bin/user_wsgi_wrapper.py", line 154, in call app_iterator = self.app(environ, start_response) File "/bin/user_wsgi_wrapper.py", line 170, in import_error_application raise e ImportError: No module named wsgi

Hi there,

Make sure you have the right version of django? Going to your website, it seems like you have solved this problem and you are onto the next one?

Conrad

Hi,

How did this problem been solved? I've gotten the same error in my flask application.

Hi,

Can any PythonAnyWhere staff help to answer this topic?

The django version mismatch I mentioned is in the wsgi.py For django 1.7+, this is correct:

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

for django <1.7, this is correct:

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

For flask, you want to import your app (ie. the app = Flask(__name__) that you have somewhere) and then save it as application in your wsgi.py

This is the settings that worked for me - this goes in your WSGI configuration file.

if path not in sys.path:
    sys.path.append(path)

from django.core.wsgi import get_wsgi_application
from django.contrib.staticfiles.handlers import StaticFilesHandler
application = StaticFilesHandler(get_wsgi_application())

Hi, can u please check this up for my site: Getting the following error msg: Error running WSGI application OSError: write error GeneratorExit

Those are safe to ignore: https://help.pythonanywhere.com/pages/GeneratorExit

A clarification -- those errors are normally safe to ignore, if you're only seeing them occasionally. If you're seeing lots of them (say, one per second) then it may be a signal that your web app is running too slowly. This could be caused by many different things -- a frequent cause is if you write a view that, when it is accessed, it makes a request to an external site, and that external site is running slowly. Or it could be a bug elsewhere in your code making it do an infinite loop -- or something like that.