我试图使用apache和mod_wsgi来解决django项目,但是得到了这个错误:
ImportError: DLL load failed: %1 n\x92est pas une application Win32 valide
这是我的wsgi.py文件
import os, sys
sys.path.append('C:/Users/abda/applica/projet/')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "projet.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
这是httpd.conf文件中的代码
WSGIScriptAlias /t C:/Users/abda/applica/test.py
WSGIScriptAlias / C:/Users/abda/applica/projet/projet/wsgi.py
Alias /media/ C:/Users/abda/applica/projet/www/media/
Alias /static/ C:/Users/abda/applica/projet/www/static/
<Directory /abda/applica/projet/projet>
<Files wsgi.py>
Require all granted
</Files>
</Directory>`
返回日志错误
[Mon May 12 15:00:17.476950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] mod_wsgi (pid=13888): Target WSGI script 'C:/Users/abda/applica/projet/projet/wsgi.py' cannot be loaded as Python module.
[Mon May 12 15:00:17.476950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] mod_wsgi (pid=13888): Exception occurred processing WSGI script 'C:/Users/abda/applica/projet/projet/wsgi.py'.
[Mon May 12 15:00:17.476950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] Traceback (most recent call last):
[Mon May 12 15:00:17.476950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] File "C:/Users/abda/applica/projet/projet/wsgi.py", line 11, in <module>
[Mon May 12 15:00:17.477950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] from django.core.wsgi import get_wsgi_application
[Mon May 12 15:00:17.477950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] File "C:\\Python27\\lib\\site-packages\\django\\core\\wsgi.py", line 1, in <module>
[Mon May 12 15:00:17.477950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] from django.core.handlers.wsgi import WSGIHandler
[Mon May 12 15:00:17.477950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] File "C:\\Python27\\lib\\site-packages\\django\\core\\handlers\\wsgi.py", line 9, in <module>
[Mon May 12 15:00:17.478950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] from django import http
[Mon May 12 15:00:17.478950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] File "C:\\Python27\\lib\\site-packages\\django\\http\\__init__.py", line 1, in <module>
[Mon May 12 15:00:17.478950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] from django.http.cookie import SimpleCookie, parse_cookie
[Mon May 12 15:00:17.478950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] File "C:\\Python27\\lib\\site-packages\\django\\http\\cookie.py", line 3, in <module>
[Mon May 12 15:00:17.479950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] from django.utils.encoding import force_str
[Mon May 12 15:00:17.479950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] File "C:\\Python27\\lib\\site-packages\\django\\utils\\encoding.py", line 10, in <module>
[Mon May 12 15:00:17.480950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] from urllib import quote
[Mon May 12 15:00:17.480950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] File "C:\\Python27\\Lib\\urllib.py", line 26, in <module>
[Mon May 12 15:00:17.481950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] import socket
[Mon May 12 15:00:17.482950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] File "C:\\Python27\\Lib\\socket.py", line 47, in <module>
[Mon May 12 15:00:17.482950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] import _socket
[Mon May 12 15:00:17.482950 2014] [:error] [pid 13888:tid 768] [client 127.0.0.1:60886] ImportError: DLL load failed: %1 n\x92est pas une application Win32 valide.
我使用django1.5和apache2.4
答案 0 :(得分:0)
您的Apache HTTP服务器是否针对32位或64位处理器进行了编译?看起来DLL正在寻找32位版本的Windows。
答案 1 :(得分:0)
解决了
所有apache / wsgi_mod.so和python需要是64位或32位http://modwsgi.readthedocs.org/en/latest/installation-guides/installation-on-windows.html
答案 2 :(得分:0)
您可以尝试使用32位Apache Http Server吗? XAMPP有一个可以让它更容易测试。