ModuleNotFoundError: Нет модуля с именем 'encodings'. Развертывание Django с помощью mod-wsgi и apache
Я разворачиваю проект Django с mod_wsgi и Apache на Microsoft Windows Server 2019. Я не могу найти правильное решение этой проблемы в Интернете. Я не знаю, почему mod-wsgi не загружает модули python?
Вот мой httpd.conf
ServerName xx.xx.xx.xx:80
# Django Project
LoadFile "C:/Users/abc/AppData/Local/Programs/Python/Python39/python39.dll"
LoadModule wsgi_module "C:/Users/abc/AppData/Local/Programs/Python/Python39/lib/site-packages/mod_wsgi/server/mod_wsgi.cp39-win_amd64.pyd"
WSGIPythonHome "C:/Users/abc/AppData/Local/Programs/Python/Python39"
WSGIScriptAlias / "C:/inetpub/wwwroot/myproject/django/myapp/wsgi.py"
WSGIPythonPath "C:/inetpub/wwwroot/myproject/django/"
<Directory "C:/inetpub/wwwroot/myproject/django/myapp/">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static "C:/inetpub/wwwroot/myproject/django/static/"
<Directory "C:/inetpub/wwwroot/myproject/django/static/">
Require all granted
</Directory>
Когда я выполняю команду:
./httpd.exe -k start
Я получаю эту ошибку в логах. И сервер не запускается.
Starting the 'Apache2.4' service
The 'Apache2.4' service is running.
pm_winnt:notice] [pid 6896:tid 552] AH00455: Apache/2.4.49 (Win64) mod_wsgi/4.9.0 Python/3.9 configured -- resuming normal operations
[Tue Sep 28 19:25:46.975430 2021] [mpm_winnt:notice] [pid 6896:tid 552] AH00456: Apache Lounge VS16 Server built: Sep 12 2021 10:23:43
[Tue Sep 28 19:25:46.975430 2021] [core:notice] [pid 6896:tid 552] AH00094: Command line: 'C:\\Apache24\\bin\\httpd.exe -d C:/Apache24'
[Tue Sep 28 19:25:46.991023 2021] [mpm_winnt:notice] [pid 6896:tid 552] AH00418: Parent: Created child process 9780
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\\abc\\AppData\\Local\\Programs\\Python\\Python39'
sys.base_exec_prefix = 'C:\\Users\\abc\\AppData\\Local\\Programs\\Python\\Python39'
sys.platlibdir = 'lib'
sys.executable = 'C:\\Apache24\\bin\\httpd.exe'
sys.prefix = 'C:\\Users\\abc\\AppData\\Local\\Programs\\Python\\Python39'
sys.exec_prefix = 'C:\\Users\\abc\\AppData\\Local\\Programs\\Python\\Python39'
sys.path = [
'C:\\Users\\abc\\AppData\\Local\\Programs\\Python\\Python39\\python39.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 0x00002870 (most recent call first):
<no Python frame>
[Tue Sep 28 19:25:48.783607 2021] [mpm_winnt:crit] [pid 6896:tid 552] AH00419: master_main: create child process failed. Exiting.