Windows8.1 x64 -Python3.4.1(pyzo_x64-2014a.win64)- Apache httpd-2.4.10-win64 - mod_wsgi-3.5.ap24.win-amd64-py3.4
如何设置多个路径?
似乎只设置了最后一条路径。
WSGIPythonPath C:/test1;C:/test2;C:/test3在Apache日志文件中(包含LogLevel信息):
mod_wsgi (pid=3568): Initializing Python.
mod_wsgi (pid=3568): Attach interpreter ''.
mod_wsgi (pid=3568): Adding '(null)' to path.
mod_wsgi (pid=3568): Adding '(null)' to path.
mod_wsgi (pid=3568): Adding 'C:/test3' to path.
AH00354: Child: Starting 64 worker threads.与以下结果相同:
WSGIPythonPath "C:/test1;C:/test2;C:/test3"这不起作用:
WSGIPythonPath "C:/test1";"C:/test2";"C:/test3"因为WSGIPythonPath只接受一个参数。
谢谢。
发布于 2016-08-24 08:55:24
作为使用WSGIPythonPath指令添加目录的替代方法,您可以从代码中将目录添加到path:
import sys, os
paths = ['C:\test1', 'C:\test2', 'C:\test3']
for path in paths:
if path not in sys.path:
sys.path.append(path)或者,如果您需要添加当前目录(对于Flask /Webapp2来说并不少见),您可以放置
在main.py中,您可以将以下内容置于其他导入内容之上:
import sys, os
path = os.path.dirname(os.path.abspath(__file__))
if path not in sys.path:
sys.path.append(path)假设您的Apache服务器配置类似于:
WSGIScriptAlias /scripts "C:/web/wsgi_scripts/main.py"
WSGICallableObject app
<Directory "C:/web/wsgi_scripts">
<Files main.py>
Require all granted
</Files>
</Directory>https://stackoverflow.com/questions/26163113
复制相似问题