WSGIPythonPath应该在我的virtualenv中指向何处? [英] Where should WSGIPythonPath point in my virtualenv?

查看:74
本文介绍了WSGIPythonPath应该在我的virtualenv中指向何处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在虚拟环境中,lib内有一个名为python2.7的文件夹.

I have a folder called python2.7 inside of lib in the virtual environment.

在阅读了六篇教程之后,我无法弄清楚我想把WSGIPythonPath指向什么.我见过一些指向site-packages的指针,但有些是由冒号:分隔的列表.

After reading half a dozen tutorials, I can't figure out exactly what I'm suppose to point the WSGIPythonPath to. I've seen some pointing to site-packages but some have been a colon : separated list.

Syntax error on line 1019 of /etc/httpd/conf/httpd.conf:
WSGIPythonPath cannot occur within <VirtualHost> section

WSGIPythonPath应该在我的virtualenv中指向何处?

Where should WSGIPythonPath point in my virtualenv?

推荐答案

您会收到错误消息,因为 VirtualGI 上下文中无法使用 WSGIPythonPath 指令.您必须在主Apache配置文件中声明它.如果仍要指向VirtualHost上下文中virtualenv中的目录,请改用 WSGIDaemonProcess 指令,它具有一个python-path选项供您声明相关的python目录.

You are getting the error because WSGIPythonPath Directive cannot be used inside the VirtualHost context. You have to declare it inside your main Apache configuration file. If you still want to point to the directories in your virtualenv inside the VirtualHost context, Use WSGIDaemonProcess Directive instead, it has a python-path option for you to declare your relevant python directories.

例如:您的虚拟主机配置文件应如下所示:

For example: your virtual host configuration file should look something like this:

<VirtualHost *:80>
ServerName example.com
CustomLog logs/example.com-access_log common
ErrorLog logs/example.com-error_log

WSGIDaemonProcess example.com python-path=/virtualenvpathto/site-packages:/pathto/exampleprojecthome
WSGIProcessGroup example.com

...
</VirtualHost>

当您有多个要添加到$ PYTHON_PATH环境变量的python目录时,使用全冒号:,这样说 import example.foo 可以正常工作.在上面的示例中,有两个目录,根据您如何设置项目,它们可以更多或更少.

The full colon : is used when you have more than one python directories you want to be added to $PYTHON_PATH environment variable so that say import example.foo works fine. In the above example, there are two directories, they could be more or less depending on how you have setup your project.

如果您在Windows上,请使用分号;而不是完整的冒号.

If you are on windows, use semicolon ; instead of full colon.

我希望这会有所帮助.

这篇关于WSGIPythonPath应该在我的virtualenv中指向何处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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