mod_wsgi (pid=10144, process='', application='localhost|'): Failed to parse WSGI script file 'C:/Apa

[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 detailspython

 

是由於 wsgi.py中沒有添加 # -*- coding: utf-8 -*-  apache

添加後wsgi.py的內容以下,就ok了django

# -*- coding: utf-8 -*-
"""
WSGI config for HelloWorld project.app

It exposes the WSGI callable as a module-level variable named ``application``.this

For more information on this file, see
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""spa

import osorm

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) ip

sys.path.append(project) #這個路徑是項目主目錄,如F:/mysite,必定要加上utf-8

from django.core.wsgi import get_wsgi_applicationget

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "HelloWorld.settings")

application = get_wsgi_application()

相關文章
相關標籤/搜索