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

前端 未结 10 939
我寻月下人不归
我寻月下人不归 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

    This line is certainly wrong:

    sys.path.append('/usr/lib/python2.4/site-packages/django')
    

    Install Django with/for the version of Python that mod_wsgi was built against.

    0 讨论(0)
  • 2021-02-06 23:33

    Hello!

    If you use deb-distributive of Linux (Debian, Ubuntu, etc), edit the file

    /etc/apache2/modules/wsgi.load
    

    This file contained path to correct wsgi-library (for active version Python interpreter). If you use Python2.6, change string

    LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so-2.7
    

    to

    LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so-2.6
    

    Also, you can change soft link to mod_wsgi module:

    cd /usr/lib/apache2/modules
    ln -s mod_wsgi.so-2.6 mod_wsgi.so
    

    Not forget change link to file in /etc/apache2/modules/wsgi.load and restart apache server

    service apache2 restart
    

    P.S. Sorry for my bad English

    0 讨论(0)
  • 2021-02-06 23:35

    Wrong:

    WSGIDaemonProcess www.example.com python-path=~/virtualenvs/virt1/lib/python2.7
    

    Right:

    WSGIDaemonProcess www.example.com python-path=/home/user/virtualenvs/virt1/lib/python2.7
    

    I spent way too much time trying to figure out why my virtualenv wasn't loading django properly.

    0 讨论(0)
  • 2021-02-06 23:36

    I solved the problem by adding location of site-packages, where I have kept django subdirectory (/Library/python/2.7/site-packages) to WSGIDaemonProcess:

    WSGIDaemonProcess www.example.com processes=2 threads=15 display-name=%{GROUP} 
        python-path=/Library/python/2.7/site-packages
    

    If you are using embedded server mode use in httpd.conf:

    WSGIPythonPath /Library/python/2.7/site-packages
    
    0 讨论(0)
提交回复
热议问题