Django阿帕奇错误:没有命名为encoding'的模块。Windows Server 2008 R2标准版 [英] Django Apache error: No module named 'encodings'. Windows server 2008 R2 Standard

查看:17
本文介绍了Django阿帕奇错误:没有命名为encoding'的模块。Windows Server 2008 R2标准版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从git克隆repo。我创建venv:

python -m venv myenv
/myenv/scripts/activate.bat
pip install -r requirements.txt
pip install mod_wsgi-4.6.5+ap24vc14-cp36-cp36m-win_amd64.whl

如果我从myvenv运行:

python manage.py runserver

是工作!

如果我从Apache运行,则会出现错误:

[Wed Oct 30 10:51:18.732028 2019] [mpm_winnt:notice] [pid 352:tid 168] AH00455: Apache/2.4.41 (Win64) mod_wsgi/4.6.5 Python/3.6 configured -- resuming normal operations
[Wed Oct 30 10:51:18.732028 2019] [mpm_winnt:notice] [pid 352:tid 168] AH00456: Apache Lounge VS16 Server built: Aug  9 2019 16:46:32
[Wed Oct 30 10:51:18.732028 2019] [core:notice] [pid 352:tid 168] AH00094: Command line: 'httpd -d C:/Apache24'
[Wed Oct 30 10:51:18.732028 2019] [mpm_winnt:notice] [pid 352:tid 168] AH00418: Parent: Created child process 1748
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00000354 (most recent call first):
[Wed Oct 30 10:51:23.677228 2019] [mpm_winnt:crit] [pid 352:tid 168] AH00419: master_main: create child process failed. Exiting.

下面的HTTPD.conf:

LoadFile "c:/<>/python/python36/python36.dll"
LoadModule wsgi_module "c:/envs/myproject/lib/site-packages/mod_wsgi/server/mod_wsgi.cp36-win_amd64.pyd"


WSGIScriptAlias / "c:/<myproject>/wsgi.py"
WSGIPythonHome "c:/envs/myproject"
WSGIPythonPath "c:/<myproject>"


Alias /static/ "c:/<myproject>/static/"
<Directory "c:/<myproject>/static">
    Require all granted
</Directory>

<Directory c:/<myproject>>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
<Directory c:/<myproject>/attachments>
    Require all granted
</Directory>
我将PYTHOME和PYTHONPATH设置为"C:UsersuserAppDataLocalProgramsPythonPython36;C:UsersuserAppDataLocalProgramsPythonPython36Scripts"

我看了很多问题,例如:Fatal Python error on Windows 10 ModuleNotFoundError: No module named 'encodings' 但此错误仅在Apache中出现。

推荐答案

幸运的是,我做到了。

我在Windows上使用的是"Viralenvwrapper"。这真的很有帮助。

pip install virtualenvwrapper-win
mkvirtualenv myenv
pip install -r requirements.txt
pip install mod_wsgi-4.6.5+ap24vc14-cp36-cp36m-win_amd64.whl

是工作。

这篇关于Django阿帕奇错误:没有命名为encoding&#39;的模块。Windows Server 2008 R2标准版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆