简体   繁体   English

如何在mod_python中添加python路径

[英]how to add python path in mod_python

Hi I am using mod_python and I have a python module AA in a directory X and in directory XI have sub directories which has other modules which are imported in AA. 嗨,我正在使用mod_python,我在目录X中有一个python模块AA,在目录XI中有一个子目录,该子目录中有其他模块,这些其他模块都在AA中导入了。 I am importing AA in BB. 我正在BB中导入AA。 when I run BB it fails to load modules imported in AA. 当我运行BB时,无法加载AA中导入的模块。

It's a python path issue, but the issue is how to dynamically set the path to the users workspace. 这是一个python路径问题,但问题是如何动态设置用户工作区的路径。

the workspace differs for each users. 每个用户的工作空间都不同。

Please help me on this. 请帮我。

to update I am using 更新我正在使用

sys. path.append(classpath)

in my BB script but still it fails. 在我的BB脚本中,但仍然失败。

my vhost file has following added in Directory tag : 我的vhost文件在Directory标签中添加了以下内容:

AddHandler cgi-script .py
PythonHandler mod_python
PythonDebug On

Python path can be added using the PythonPath directive. 可以使用PythonPath指令添加Python路径。 It should work in the server, virtual host, directory and .htaccess contexts. 它应该在服务器,虚拟主机,目录和.htaccess上下文中工作。

PythonPath "['/path/to/site1', '/path/to/site2']"

http://modpython.org/live/current/doc-html/directives.html#pythonpath http://modpython.org/live/current/doc-html/directives.html#pythonpath

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM