在pythonanywhere上运行WSGI应用程序django时出错

问题描述 投票:0回答:1

我有点着急,但是长期困扰这个问题。我不知道该怎么办。我的错误引发了关于WSGI的错误。当我看到错误日志时,

2019-12-16 08:53:45,120: Error running WSGI application
2019-12-16 08:53:45,121:   File "/var/www/lej970526_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/lej970526_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/lej970526_pythonanywhere_com_wsgi.py", line 3
2
2019-12-16 10:40:06,493:     ^
2019-12-16 10:40:06,493: 
   

这就是我所见。

/ var / www / lej970526_pythonanywhere_com_wsgi.py还包括

  
   
import os
import sys

path = 'home/lej970526/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 hereenter image description here
django wsgi pythonanywhere django-wsgi
1个回答
0
投票

在您的代码中,您有这个:

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

这是无效的Python;如果if语句中的条件为True,则需要缩进运行的代码,如下所示:

if path not in sys.path:
    sys.path.append(path)
© www.soinside.com 2019 - 2024. All rights reserved.