Windows上的Python-Django-WSGI-Apache - “ImportError:没有名为site的模块”

时间:2016-11-17 08:50:43

标签: python django windows apache mod-wsgi

我正在尝试使用wsgi mod在Windows服务器上连接django和apache。 当我运行httpd.exe时,它会立即关闭。 在error.log中我得到了这个:

[Thu Nov 17 00:44:19.918823 2016] [wsgi:warn] [pid 520:tid 452] mod_wsgi: Compiled for Python/2.7.9+.
[Thu Nov 17 00:44:19.918823 2016] [wsgi:warn] [pid 520:tid 452] mod_wsgi: Runtime using Python/2.7.11.
[Thu Nov 17 00:44:19.918823 2016] [mpm_winnt:notice] [pid 520:tid 452] AH00455: Apache/2.4.23 (Win64) mod_wsgi/4.4.12 Python/2.7.11 configured -- resuming normal operations
[Thu Nov 17 00:44:19.918823 2016] [mpm_winnt:notice] [pid 520:tid 452] AH00456: Apache Lounge VC10 Server built: Jul  9 2016 11:59:00
[Thu Nov 17 00:44:19.918823 2016] [core:notice] [pid 520:tid 452] AH00094: Command line: 'httpd -d C:/Apache24'
[Thu Nov 17 00:44:19.918823 2016] [core:debug] [pid 520:tid 452] log.c(1543): AH02639: Using SO_REUSEPORT: no (0)
[Thu Nov 17 00:44:19.918823 2016] [mpm_winnt:notice] [pid 520:tid 452] AH00418: Parent: Created child process 2308
[Thu Nov 17 00:44:19.918823 2016] [mpm_winnt:debug] [pid 520:tid 452] mpm_winnt.c(429): AH00402: Parent: Sent the scoreboard to the child
[Thu Nov 17 00:44:20.043916 2016] [wsgi:warn] [pid 2308:tid 448] mod_wsgi: Compiled for Python/2.7.9+.
[Thu Nov 17 00:44:20.043916 2016] [wsgi:warn] [pid 2308:tid 448] mod_wsgi: Runtime using Python/2.7.11.
[Thu Nov 17 00:44:20.043916 2016] [mpm_winnt:debug] [pid 2308:tid 448] mpm_winnt.c(1718): AH00453: Child process is running
[Thu Nov 17 00:44:20.043916 2016] [wsgi:info] [pid 2308:tid 448] mod_wsgi (pid=2308): Initializing Python.
ImportError: No module named site
[Thu Nov 17 00:44:20.059467 2016] [mpm_winnt:crit] [pid 520:tid 452] AH00419: master_main: create child process failed. Exiting.
[Thu Nov 17 00:44:20.059467 2016] [core:info] [pid 520:tid 452] AH00096: removed PID file C:/Apache24/logs/httpd.pid (pid=520)

我的python版本是2.7.11 我的apache版本是2.4.23

1 个答案:

答案 0 :(得分:1)

我找到了问题的答案: apache服务器运行python,但不是正确的。 我必须具体使用httpd.conf文件中的python路径,如下所示:

WSGIPythonHome C:/Python27

这表示了python的路径。