[Wed Jan 31 19:01:18.044138 2018] [wsgi:error] [pid 10144:tid 804] [client ::1:54225] mod_wsgi (pid=10144, process=‘‘, application=‘localhost|‘): Failed to parse WSGI script file ‘C:/Apache24/hello/HelloWorld/HelloWorld/wsgi.py‘.
[Wed Jan 31 19:01:18.045138 2018] [wsgi:error] [pid 10144:tid 804] [client ::1:54225] mod_wsgi (pid=10144): Exception occurred processing WSGI script ‘C:/Apache24/hello/HelloWorld/HelloWorld/wsgi.py‘.
[Wed Jan 31 19:01:18.045138 2018] [wsgi:error] [pid 10144:tid 804] [client ::1:54225] File "C:/Apache24/hello/HelloWorld/HelloWorld/wsgi.py", line 19
[Wed Jan 31 19:01:18.045138 2018] [wsgi:error] [pid 10144:tid 804] [client ::1:54225] SyntaxError: Non-ASCII character ‘\\xe8‘ in file C:/Apache24/hello/HelloWorld/HelloWorld/wsgi.py on line 19, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
是因为 wsgi.py中没有添加 # -*- coding: utf-8 -*-
添加后wsgi.py的内容如下,就ok了
# -*- coding: utf-8 -*-
"""
WSGI config for HelloWorld project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""
import os
import sys
#Calculate the path based on the location of the WSGI script.
apache_configuration= os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
workspace = os.path.dirname(project)
sys.path.append(project) #这个路径是项目主目录,如F:/mysite,一定要加上
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "HelloWorld.settings")
application = get_wsgi_application()