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

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

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

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

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

python大神给出的解决方案

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

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

<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正常工作。在上面的示例中,有两个目录,根据您如何设置项目,它们可以更多或更少。

如果您在Windows上,请使用分号;而不是全冒号。

我希望这有帮助。

Python sqlite3数据库已锁定 - python

我在Windows上使用Python 3和sqlite3。我正在开发一个使用数据库存储联系人的小型应用程序。我注意到,如果应用程序被强制关闭(通过错误或通过任务管理器结束),则会收到sqlite3错误(sqlite3.OperationalError:数据库已锁定)。我想这是因为在应用程序关闭之前,我没有正确关闭数据库连接。我已经试过了: connectio…

Python pytz时区函数返回的时区为9分钟 - python

由于某些原因,我无法从以下代码中找出原因:>>> from pytz import timezone >>> timezone('America/Chicago') 我得到:<DstTzInfo 'America/Chicago' LMT-1 day, 18:09:00 STD…

用大写字母拆分字符串,但忽略AAA Python Regex - python

我的正则表达式:vendor = "MyNameIsJoe. I'mWorkerInAAAinc." ven = re.split(r'(?<=[a-z])[A-Z]|[A-Z](?=[a-z])', vendor) 以大写字母分割字符串,例如:'我的名字是乔。 I'mWorkerInAAAinc”变成…

如何打印浮点数的全精度[Python] - python

我编写了以下函数,其中传递了x,y的值:def check(x, y): print(type(x)) print(type(y)) print(x) print(y) if x == y: print "Yes" 现在当我打电话check(1.00000000000000001, 1.0000000000000002)它正在打印:<…

PyCharm中Django的文档字符串中未解决的引用 - python

我在Django的专案中使用Google Style Python Docstrings like in this Example。当我创建一个类并在文档字符串中使用属性符号时,Pycharm总是说-“未解决的引用”。class Post(models.Model): """ Class for posts. Attribute…