djangowsgipythonanywheredjango-wsgi

Error running WSGI application django Error on pythonanywhere


I'm bit in hurry but stuck on this problem for a long time. I don't know what should I do. My error throws an error about WSGI. When I saw Error Log,

2019-12-16 08:53:45,120: Error running WSGI application
2019-12-16 08:53:45,121:   File "/var/www/000_pythonanywhere_com_wsgi.py", line 3
 
2019-12-16 08:53:45,122: SyntaxError: invalid character in identifier

2019-12-16 08:54:12,944: Error running WSGI application
2019-12-16 08:54:12,946:   File "/var/www/000_pythonanywhere_com_wsgi.py", line 3

2019-12-16 08:54:12,947: SyntaxError: invalid character in identifier
2
2019-12-16 08:54:14,487: Error running WSGI application
2019-12-16 08:54:14,487:   File "/var/www/000_pythonanywhere_com_wsgi.py", line 3
2
2019-12-16 10:40:06,493:     ^
2019-12-16 10:40:06,493: 
   

This is what I saw.

/var/www/000_pythonanywhere_com_wsgi.py also includes

  
   
import os
import sys

path = 'home/000/koo'
if path not in sys.path:
sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

from django.core.wsgi import get_wsgi_application
from django.contrib.staticfiles.handlers import StaticFilesHandler
application = StaticFilesHandler(get_wsgi_application())
enter image description here enter image description here


Solution

  • In your code, you have this:

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

    That's not valid Python; you need to indent the code that is run if the condition in the if statement is True, like this:

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