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.

ImportError: No module named django.core.wsgi

I see your web app is using a virtualenv. Have you installed Django into the env?

YES

Can I take a look at your files? We can see them from our admin interface, but we always ask for permission first.

okk

okk

You've somehow created a virtualenv that has both Python 3.5 and 2.7 packages installed and you've only installed Django into the 3.5 version where your web app is using 2.7.

So, What I need to do?

Recreate your virtualenv with only Python 2.7 and with Django installed.

If you can. Please do it for me I am very thankful of you please make it live.

We're glad to help you work out what you did wrong and what you need to do to fix it, but we don't do it for you.

i have done but still getting error.

What error?

wsgi error

What is the actual error? "wsgi error" could mean anything.

Error running WSGI application 2017-09-01 14:56:10,093: ImportError: No module named django.core.wsgi 2017-09-01 14:56:10,093: File "/var/www/jks9650_pythonanywhere_com_wsgi.py", line 60, in <module> 2017-09-01 14:56:10,093: from django.core.wsgi import get_wsgi_application

it shows same error line 60 if there is only 16 or 17 line of code.

That error is from 3 days ago. I'm pretty sure it's not useful for the current issue.

means what ???

Hi there, just picking up on this while Glenn is elsewhere. We have some debugging tips for common problems with imports here: https://help.pythonanywhere.com/pages/DebuggingImportError

Can I ask you to try them out and report back what you discover?