I am trying to host a Django app on Apache 2.4. The service won't start and produces the folowing error
[Thu Oct 28 13:12:37.898096 2021] [mpm_winnt:notice] [pid 5144:tid 628] AH00418: Parent: Created child process 7828
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = 'python'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'C:\\apache24\\bin\\httpd.exe'
sys.base_prefix = 'C:\\Users\\myuser\\AppData\\Local\\Programs\\Python\\Python310'
sys.base_exec_prefix = 'C:\\Users\\myuser\\AppData\\Local\\Programs\\Python\\Python310'
sys.platlibdir = 'lib'
sys.executable = 'C:\\apache24\\bin\\httpd.exe'
sys.prefix = 'C:\\Users\\myuser\\AppData\\Local\\Programs\\Python\\Python310'
sys.exec_prefix = 'C:\\Users\\myuser\\AppData\\Local\\Programs\\Python\\Python310'
sys.path = [
'C:\\Users\\myuser\\AppData\\Local\\Programs\\Python\\Python310\\python310.zip',
'.\\DLLs',
'.\\lib',
'C:\\apache24\\bin',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00000fa0 (most recent call first):
<no Python frame>
[Thu Oct 28 13:12:38.413708 2021] [mpm_winnt:crit] [pid 5144:tid 628] AH00419: master_main: create child process failed. Exiting.
The server ran before I did all the configurations and went to the "it worked" screen.
I think it has to do with either my httpd-host conf
<Directory /some/path/project>
Require all granted
</Directory>
<VirtualHost *:80>
ServerName localhost
WSGIPassAuthorization On
ErrorLog "C:/Users/myuser/Desktop/app.error.log"
CustomLog "C:/Users/myuser/Desktop/app.access.log" combined
WSGIScriptAlias / "C:/Users/myuser/Desktop/app/wsgi_windows.py"
<Directory "C:/Users/myuser/Desktop/app/EmployeeKiosk">
<Files wsgi_windows.py>
Require all granted
</Files>
</Directory>
Alias /static "C:/Users/myuser/Desktop/app/static"
<Directory "C:/Users/myuser/Desktop/app/static">
Require all granted
</Directory>
</VirtualHost>
OR My wsgi_windows py
import os
import sys
import site
# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('C:/Users/myuser/Desktop/app/appEnv/Lib/site-packages')
# Add the app's directory to the PYTHONPATH
sys.path.append('C:/Users/myuser/Desktop/app')
sys.path.append('C:/Users/myuser/Desktop/app/appEnv')
os.environ['DJANGO_SETTINGS_MODULE'] = 'app.settings'
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
I am using a virtual enviroment and there aren't a whole lot of clear instructions on how to handle that.
Edit: I should mention this is a windows system. according to https://code.google.com/archive/p/modwsgi/wikis/ConfigurationDirectives.wiki#WSGIPythonHome You can not use WSGIPythonHome to override the PYTHONEXECUTABLE path. But, the default should be correct as it match what the error lists.
