init_fs_encoding: 获取文件系统编码的 Python 编解码器失败
init_fs_encoding: failed to get the Python codec of the filesystem encoding
我是 运行 Apache 上的 Django 网站。
这是我的 httpd.conf
文件的尾部。
ServerName 127.0.0.1:8080
# Django Project
LoadFile "c:/python39/python39.dll"
LoadModule wsgi_module "c:/python39/lib/site-packages/mod_wsgi/server/mod_wsgi.cp39-win_amd64.pyd"
WSGIPythonHome "c:/python39/"
WSGIScriptAlias / "C:/pd_videowebapp/mysite/wsgi.py"
WSGIPythonPath "C:/pd_videowebapp/"
<Directory "C:/pd_videowebapp/mysite/">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static "C:/pd_videowebapp/static/"
<Directory "C:/pd_videowebapp/static/">
Require all granted
</Directory>
这里是 error.log
文件的尾部:
The 'Apache2.4' service is restarting.
Starting the 'Apache2.4' service
The 'Apache2.4' service is running.
pm_winnt:notice] [pid 4472:tid 420] AH00455: Apache/2.4.51 (Win64) mod_wsgi/4.9.0 Python/3.9 configured -- resuming normal operations
[Wed Oct 13 08:31:28.026005 2021] [mpm_winnt:notice] [pid 4472:tid 420] AH00456: Apache Lounge VS16 Server built: Oct 7 2021 16:27:02
[Wed Oct 13 08:31:28.026005 2021] [core:notice] [pid 4472:tid 420] AH00094: Command line: 'C:\Apache24\bin\httpd.exe -d C:/Apache24'
[Wed Oct 13 08:31:28.041641 2021] [mpm_winnt:notice] [pid 4472:tid 420] AH00418: Parent: Created child process 2676
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:\Python39'
sys.base_exec_prefix = 'C:\Python39'
sys.platlibdir = 'lib'
sys.executable = 'C:\Apache24\bin\httpd.exe'
sys.prefix = 'C:\Python39'
sys.exec_prefix = 'C:\Python39'
sys.path = [
'C:\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 0x00001bd8 (most recent call first):
<no Python frame>
[Wed Oct 13 08:31:28.385413 2021] [mpm_winnt:crit] [pid 4472:tid 420] AH00419: master_main: create child process failed. Exiting.
Windows 10 个用户:
- 按工具栏上的 Windows 徽标。
- 键入并打开
Edit the system environment variables
。
- 在
Advance
选项卡中按 Environment Variables
按钮。
- 对于
System variables
按 New
按钮。
Variable name
将是 PYTHONHOME,Variable value
将是 python.exe
所在的路径(即 c:/users/administrator/anaconda3/envs/my_env_name)。然后按 OK
.
- 再次
System variables
按 New
按钮。
Variable name
将是 PYTHONPATH,Variable value
将是 site-packages
文件夹的路径(即 C:/Users/Administrator/anaconda3/envs/my_env_name/Lib/site-packages)。然后按 OK
.
我是 运行 Apache 上的 Django 网站。
这是我的 httpd.conf
文件的尾部。
ServerName 127.0.0.1:8080
# Django Project
LoadFile "c:/python39/python39.dll"
LoadModule wsgi_module "c:/python39/lib/site-packages/mod_wsgi/server/mod_wsgi.cp39-win_amd64.pyd"
WSGIPythonHome "c:/python39/"
WSGIScriptAlias / "C:/pd_videowebapp/mysite/wsgi.py"
WSGIPythonPath "C:/pd_videowebapp/"
<Directory "C:/pd_videowebapp/mysite/">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static "C:/pd_videowebapp/static/"
<Directory "C:/pd_videowebapp/static/">
Require all granted
</Directory>
这里是 error.log
文件的尾部:
The 'Apache2.4' service is restarting.
Starting the 'Apache2.4' service
The 'Apache2.4' service is running.
pm_winnt:notice] [pid 4472:tid 420] AH00455: Apache/2.4.51 (Win64) mod_wsgi/4.9.0 Python/3.9 configured -- resuming normal operations
[Wed Oct 13 08:31:28.026005 2021] [mpm_winnt:notice] [pid 4472:tid 420] AH00456: Apache Lounge VS16 Server built: Oct 7 2021 16:27:02
[Wed Oct 13 08:31:28.026005 2021] [core:notice] [pid 4472:tid 420] AH00094: Command line: 'C:\Apache24\bin\httpd.exe -d C:/Apache24'
[Wed Oct 13 08:31:28.041641 2021] [mpm_winnt:notice] [pid 4472:tid 420] AH00418: Parent: Created child process 2676
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:\Python39'
sys.base_exec_prefix = 'C:\Python39'
sys.platlibdir = 'lib'
sys.executable = 'C:\Apache24\bin\httpd.exe'
sys.prefix = 'C:\Python39'
sys.exec_prefix = 'C:\Python39'
sys.path = [
'C:\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 0x00001bd8 (most recent call first):
<no Python frame>
[Wed Oct 13 08:31:28.385413 2021] [mpm_winnt:crit] [pid 4472:tid 420] AH00419: master_main: create child process failed. Exiting.
Windows 10 个用户:
- 按工具栏上的 Windows 徽标。
- 键入并打开
Edit the system environment variables
。 - 在
Advance
选项卡中按Environment Variables
按钮。 - 对于
System variables
按New
按钮。 Variable name
将是 PYTHONHOME,Variable value
将是python.exe
所在的路径(即 c:/users/administrator/anaconda3/envs/my_env_name)。然后按OK
.- 再次
System variables
按New
按钮。 Variable name
将是 PYTHONPATH,Variable value
将是site-packages
文件夹的路径(即 C:/Users/Administrator/anaconda3/envs/my_env_name/Lib/site-packages)。然后按OK
.