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

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

    I solved this issue by adding the parent directory that holds my django installation to sys.path in wsgi.py. Here are my settings, FWIW:

    /home/banjer/myproject/wsgi.py:

    import os, sys
    sys.path.append('/home/banjer/django')
    sys.path.append('/home/banjer') # this line solved it
    sys.executable = '/usr/local/python-2.7.2/bin/python'
    os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
    
    import django.core.handlers.wsgi
    application = django.core.handlers.wsgi.WSGIHandler()
    

提交回复
热议问题