Domanda

I tried to deplpoy django project to work with apache and mod_wsgi but get this error:

ImportError: DLL load failed: %1 n\x92est pas une application Win32 valide

this is my wsgi.py file

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

this is the code in httpd.conf file

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>`

this the log error returned

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

I use django1.5 and apache2.4

È stato utile?

Soluzione 2

solved

All apache/ wsgi_mod.so and python need to be 64 bit or 32 bit http://modwsgi.readthedocs.org/en/latest/installation-guides/installation-on-windows.html

Altri suggerimenti

Is your Apache HTTP server compiled for 32 bit or 64 bit processor? It looks like a DLL is looking for a 32-bit version of Windows.

Can you try using the 32-bit Apache Http Server? XAMPP has one that might make it easier to test.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top