在Windows上设置mod_wsgi和金字塔

时间:2013-02-13 09:54:01

标签: python apache mod-wsgi pyramid

我一直在尝试在windows下的mod_wsgi下设置金字塔。我的应用程序是一个使用命令

创建的简单脚手架
..\Scripts\pcreate -s starter it

我的httpd.conf文件具有以下指令

LoadModule wsgi_module modules/mod_wsgi-win32-ap22py27-3.3.so
WSGIScriptAlias /x "C:/Documents and Settings/Administrator.TRANSGLOBAL/Desktop/env/pyramid.wsgi"
<Directory "C:/Documents and Settings/Administrator.TRANSGLOBAL/Desktop/env">
Order allow,deny
Allow from all
</Directory>

所以我的所有应用程序代码都在它的文件夹中。 mod_wsgi.so文件被加载到apache中,以下示例代码在pyramid.wsgi

中工作
def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]

但是当我将pyramid.wsgi代码更改为指向名为“it”的金字塔应用程序时

from pyramid.paster import get_app
import os
import sys
application = get_app('C:\Documents and Settings\Administrator.TRANSGLOBAL\Desktop\env\it\development.ini', 'main')

Apache日志会产生以下错误

File "C:/Documents and Settings/Administrator.TRANSGLOBAL/Desktop/env/pyramid.wsgi", line 11, in <module>
application = get_app('C:\\Documents and Settings\\Administrator.TRANSGLOBAL\\Desktop\\env\\it\\development.ini', 'main')
File "C:\\Python27\\lib\\site-packages\\pyramid-1.4-py2.7.egg\\pyramid\\paster.py", line 31, in get_app
app = loadapp(config_name, name=section, relative_to=here_dir, **kw)

raise DistributionNotFound(req)  # XXX put more info here
DistributionNotFound: it

1 个答案:

答案 0 :(得分:0)

经过大量的实验后,我注意到我使用的所有windows box(windows 7,windows 8和windows server 2003)都拒绝使用虚拟环境中的文件并在c中查找它的项目文件: / python27 / LIB / sitepackages

解决方案是设置我的包的dist包

..\Scripts\python setup.py sdist

然后像在任何其他应用程序中一样在dist文件夹中安装应用程序。我的apache配置保持不变。

相关问题