ImportError: No module named django.core.handlers.wsgi in install django mod_wsgi config on apache

前端 未结 10 954
我寻月下人不归
我寻月下人不归 2021-02-06 22:34

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

ImportError: No module named django.core.handlers.wsgi,

I\'v rea

10条回答
  •  [愿得一人]
    2021-02-06 23:32

    Check your site-package file permissions. None of the above solutions worked for me until I fix file permissions. Here's what's in my ssl_error_log file:

    mod_wsgi (pid=986, process='OSQA', application='xxxxxx.yyy.com|/forum'): Loading WSGI script '/data/http/osqa/osqa.wsgi'. 
    mod_wsgi (pid=986): Target WSGI script '/data/http/osqa/osqa.wsgi' cannot be loaded as Python module.
    mod_wsgi (pid=986): Exception occurred processing WSGI script '/data/http/osqa/osqa.wsgi'. Traceback (most recent call last):   File "/data/http/osqa/osqa.wsgi", line 14, in 
                import django.core.handlers.wsgi  ImportError: No module named django.core.handlers.wsgi
    

    But I solved it on my server. If you can do this on the command line, then this solution is for you:

    python
    >>> import django.core.handlers.wsgi
    >>>
    

    What worked is that I chmod go+rx site-packages libpython* (this might be overkill, but it worked for me.)

    I'm running as httpd as apache.user, and running python as root, could see the packages just fine, but my permissions were not setup correctly (to read by everyone), and that's why httpd could not read the packages.

提交回复
热议问题