开发者

Snow Leopard: Apache + mod_wsgi + django problem

开发者 https://www.devze.com 2023-03-24 12:34 出处:网络
i tried to set up apache + mod_wsgi + django on my snow leopard, but it kept gave me the same errors which listed below. i tried to follow every tutorial on the web that i could found, but still could

i tried to set up apache + mod_wsgi + django on my snow leopard, but it kept gave me the same errors which listed below. i tried to follow every tutorial on the web that i could found, but still couldn't make it work :( . (im sure all the paths are added into sys.path, but don't know why it had the import error)

[Tue Aug 02 14:47:36 2011] [error] [client 127.0.0.1]     import django.core.handlers.wsgi

[Tue Aug 02 14:47:36 2011] [error] [client 127.0.0.1] ImportError: No module named django.core.handlers.wsgi

[Tue Aug 02 14:47:36 2011] [error] [client 127.0.0.1] mod_wsgi (pid=4333): Target WSGI script '/Users/kyle/wsgi_source/django-tutorial/mysite/apache/django.wsgi' cannot be loaded as Python module.

[Tue Aug 02 14:47:36 2011] [error] [client 127.0.0.1] mod_wsgi (pid=4333): Exception occurred processing WSGI script '/Users/kyle/wsgi_source/django-tutorial/mysite/apache/django.wsgi'.

[Tue Aug 02 14:47:36 2011] [error] [client 127.0.0.1] Traceback (most recent call last):

[Tue Aug 02 14:47:36 2011] [error] [client 127.0.0.1]   File "/Users/kyle/wsgi_source/django-tutorial/mysite/apache/django.wsgi", line 8, in <module>

[Tue Aug 02 14:47:36 2011] [error] [client 127.0.0.1]     import django.core.handlers.wsgi

[Tue Aug 02 14:47:36 2011] [error] [client 127.0.0.1] ImportError: No module named django.core.handlers.wsgi

Here is the apache configuration file:

<VirtualHost *:80>
    WSGIDaemonProcess localdjango processes=2 threads=15 display-name=%{GROUP}
    WSGIProcessGroup localdjango

    ServerName localdjango

    WSGIScriptAlias / /Users/kyle/wsgi_source/django-tutorial/mysite/apache/django.wsg开发者_JAVA百科i
    <Directory /Users/kyle/wsgi_source/django-tutorial/mysite/apache>
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

here is /Users/kyle/wsgi_source/django-tutorial/mysite/apache/django.wsgi

  1 import sys
  2 import os
  3 
  4 sys.path.append('/Users/eookoo/wsgi_source/django-tutorial')
  5 
  6 os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
  7 
  8 import django.core.handlers.wsgi
  9 application = django.core.handlers.wsgi.WSGIHandler()

Thanks in advance.


It is import to know whether you are using the operating system supplied Python or not.

If you are and that is the only Python version on the system, then Django wasn't installed into it. That or if you are using a Python virtual environment, then you haven't set up your WSGI script file or mod_wsgi to use the Python virtual environment.

If you have installed a separate Python version, and Django is installed into it, then likely that mod_wsgi was compiled against the system Python version and not your version.

Alternative to the latter is that you are hitting a problem that occurs with some Python installations that caused framework linking under MacOS X to not work properly and at run time, even though mod_wsgi was compiled against your separate Python version, it is still using the system wide Python framework. In this latter case you need to rebuild mod_wsgi against your separate Python version, but this time use the '--disable-framework' option to the 'configure' script for mod_wsgi before building it.

For a general resource on MacOS X issues for mod_wsgi, ensure you read the documentation at:

http://code.google.com/p/modwsgi/wiki/InstallationOnMacOSX

0

精彩评论

暂无评论...
验证码 换一张
取 消