【发布时间】:2013-11-10 12:31:44
【问题描述】:
当我尝试在 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()
【问题讨论】:
-
只是猜测,但可能是 32 位/64 位兼容性问题...如果您有 32 位或 64 位 Windows,请尝试安装匹配的 Python。
-
我有 64 位 python,bud 32 位 Apache 和 mod_wsgi
-
可能是这个问题,你试过用32位python吗?
-
是的,你是对的。我没有安装 Python 32 位,但 Apache 和 mod_wsgi 64 位并且它工作。谢谢
-
太好了,那我来回答一下,让其他有同样问题的人可以轻松找到。
标签: python django apache mod-wsgi windows-server-2008-r2