当我尝试在 Apache 2.2、Windows server 2008 R2 和 Python 3.3 上运行 Django 1.5 时,它给了我这个错误,我认为 wsgi.py 中存在问题,但我现在不知道:这是 Apache 中的错误:
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] mod_wsgi (pid=8768): Target WSGI script 'C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/mysite/mysite/wsgi.py' cannot be loaded as Python module.
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] mod_wsgi (pid=8768): Exception occurred processing WSGI script 'C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/mysite/mysite/wsgi.py'.
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] Traceback (most recent call last):\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] File "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/mysite/mysite/wsgi.py", line 10, in <module>\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] import django.core.handlers.wsgi\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] File "C:\\Python33\\lib\\site-packages\\django\\core\\handlers\\wsgi.py", line 9, in <module>\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] from django import http\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] File "C:\\Python33\\lib\\site-packages\\django\\http\\__init__.py", line 2, in <module>\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] from django.http.request import (HttpRequest, QueryDict, UnreadablePostError,\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] File "C:\\Python33\\lib\\site-packages\\django\\http\\request.py", line 20, in <module>\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] from django.http.multipartparser import MultiPartParser\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] File "C:\\Python33\\lib\\site-packages\\django\\http\\multipartparser.py", line 10, in <module>\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] import cgi\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] File "C:\\Python33\\Lib\\cgi.py", line 38, in <module>\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] from email.parser import FeedParser\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] File "C:\\Python33\\Lib\\email\\parser.py", line 12, in <module>\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] from email.feedparser import FeedParser, BytesFeedParser\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] File "C:\\Python33\\Lib\\email\\feedparser.py", line 27, in <module>\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] from email import message\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] File "C:\\Python33\\Lib\\email\\message.py", line 16, in <module>\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] from email import utils\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] File "C:\\Python33\\Lib\\email\\utils.py", line 30, in <module>\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] import socket\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] File "C:\\Python33\\Lib\\socket.py", line 47, in <module>\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] import _socket\r
[Sun Nov 10 13:26:46 2013] [error] [client 127.0.0.1] ImportError: DLL load failed: %1 nen\xc3\xad platn\xc3\xa1 aplikace typu Win32.\r
这是 wsgi.py
import sys
import os
# workaround for various print messages stopping the app under mod_wsgi (namely South)
sys.stdout = sys.stderr
sys.path.append('D:/Rocnikova_prace/mysite')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()