如何在mod_python中添加python路径 [英] how to add python path in mod_python

查看:173
本文介绍了如何在mod_python中添加python路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用mod_python,我在目录X中有一个python模块AA,在目录X中我有一些子目录,这些子目录中有其他模块已导入AA中.我要在BB中导入AA.当我运行BB时,无法加载AA中导入的模块.

Hi I am using mod_python and I have a python module AA in a directory X and in directory X I have sub directories which has other modules which are imported in AA. I am importing AA in BB. when I run BB it fails to load modules imported in AA.

这是python路径问题,但问题是如何动态设置用户工作区的路径.

It's a python path issue, but the issue is how to dynamically set the path to the users workspace.

每个用户的工作区都不同.

the workspace differs for each users.

请帮助我.

要更新我正在使用

sys. path.append(classpath)

在我的BB脚本中,但仍然失败.

in my BB script but still it fails.

我的虚拟主机文件已在目录标记中添加了以下内容:

my vhost file has following added in Directory tag :

AddHandler cgi-script .py
PythonHandler mod_python
PythonDebug On

推荐答案

可以使用PythonPath指令添加Python路径.它应该在服务器,虚拟主机,目录和.htaccess上下文中工作.

Python path can be added using the PythonPath directive. It should work in the server, virtual host, directory and .htaccess contexts.

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

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

这篇关于如何在mod_python中添加python路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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