Apache 启动的错误日志:ModuleNotFoundError: No module named ‘encodings‘

在Windows服务器上配置Django项目时,使用Apache+mod_wsgi组合,作者遇到了因缺少encodings模块导致Apache无法启动的问题。解决方案是检查配置文件中的路径正确性,并确保设置了PYTHONHOME环境变量来指向Python的安装路径。
摘要由CSDN通过智能技术生成

在window服务器上配置django项目,使用apache+mod_wigs,

 配置文件如下:

# 监听9080端口
Listen 8000
# 加载mod_wsgi模块
LoadModule wsgi_module "c:/users/administrator/appdata/local/programs/python/python37/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd"
WSGIPythonHome "c:/users/administrator/appdata/local/programs/python/python37"
# 配置Django项目的应用程序路径
WSGIPythonPath "C:/website/website"


<VirtualHost *:8000>
    ServerName localhost
    DocumentRoot "C:/website"
    Alias /static/ "C:/website/static/"
    
    <Directory "C:/website/static">
        Require all granted
    </Directory>
    
    WSGIScriptAlias / "C:/website/website/wsgi.py"
    <Directory "C:/website/website">
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>
</VirtualHost>

报错信息

[Sun Jun 04 11:16:06.786712 2023] [core:notice] [pid 4920:tid 312] AH00094: Command line: 'C:\\Apache24\\bin\\httpd.exe -d C:/Apache24 -f C:\\Apache24\\conf\\httpd.conf'
[Sun Jun 04 11:16:06.802456 2023] [mpm_winnt:notice] [pid 4920:tid 312] AH00418: Parent: Created child process 6724
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00001a6c (most recent call first):
[Sun Jun 04 11:16:28.927629 2023] [mpm_winnt:crit] [pid 4920:tid 312] AH00419: master_main: create child process failed. Exiting.

说明:apache 启动了但是因为没有找到python的某个包“encodings” ,导致退出创建的进程。

解决办法:确认配置文件中所有的路径都是存在的,可以通过cmd命令提示符窗口运行python的命令,导入,输出模块的相关信息,然后添加环境变量PYTHONHOME

PYTHONHOME
c:/users/administrator/appdata/local/programs/python/python37

变量名为  PYTHONHOME,变量值为python的安装路径。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值