Home > Mobile >  After splitting settings.py file, mod_wsgi failed to exec Python script file. And application = get_
After splitting settings.py file, mod_wsgi failed to exec Python script file. And application = get_

Time:09-10

Hi everybody I tried to deploy my django project with apache, mod_wsgi in windows.

I splited my settings.py like this:

  • source root folder
    • project folder
      • apps
      • config
        • settings
          • init.py
          • base.py
          • local.py
          • prod.py
      • init.py
      • asgi.py
      • urls.py
      • wsgi.py
    • myenv

After I splited settings.py, Mod_wsgi failed to exec python scripts file : 'C:/user/users/desktop/source_root_folder/project_folder/wsgi.py'.

Mod_wsgi also show the exception that Exception occurred processing WSGI script : 'C:/user/users/desktop/source_root_folder/project_folder/wsgi.py'

In Apache24 error log, 'C:/user/users/desktop/source_root_folder/project_folder/wsgi.py' application = get_wsgi_application() error occured.

# project_folder/wsgi.py

import os
from django.core.wsgi import get_wsgi_application
import sys

sys.path.append('C:/Apache24/htdocs/ C:/user/users/desktop/source_root_folder')

os.environ['DJANGO_SETTINGS_MODULE'] = 'project_folder.config.settings'
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project_folder.config.settings')


application = get_wsgi_application()

how can i deal with those errors? please give me some helps.

CodePudding user response:

you need to specify the *.py settings file:

os.environ['DJANGO_SETTINGS_MODULE'] = 'project_folder.config.settings.init'
  • Related