简体   繁体   English

在Windows上使用Apache和mod_wsgi安装金字塔时出现的问题

[英]Issue while installing pyramid with apache and mod_wsgi on windows

I am trying to install a pyramid project on windows. 我正在尝试在Windows上安装金字塔项目。 The wsgi file contains: wsgi文件包含:

import os, sys

baseDir='D:\myproject\hello'
configFile = os.path.join(baseDir, 'development.ini')

sys.path.append(baseDir)
os.environ['PYTHON_EGG_CACHE'] = '/var/www/.python-eggs'

from pyramid.paster import get_app, setup_logging
setup_logging(configFile)
application = get_app(configFile, 'main')

Here 'hello' is the project name(root). 这里的“ hello”是项目名称(根)。 But while accessing it from browser, I get the following error: 但是从浏览器访问它时,出现以下错误:

 from pyramid.paster import get_app, setup_logging
 [Wed Jan 22 14:32:50 2014] [error] [client 127.0.0.1] ImportError: No module named  pyramid.paster

Can anyone help me to debug it. 谁能帮我调试它。

According to this pyramid tutorial your environment is rather uncommon and difficult to set up. 根据此金字塔教程,您的环境相当罕见且难以设置。 Nevertheless you need a python environment with pyramid installed. 不过,您需要安装金字塔的python环境。 Say hello to virtualenv. 向virtualenv问好。 You did not mention any details about using it. 您没有提及有关使用它的任何详细信息。 Below you see how WSGIDaemonProcess is configured to path of site-packages of the Python which mod_wsgi will run. 在下面,您将看到WSGIDaemonProcess如何配置为将运行mod_wsgi的Python 站点包的路径。 Do not manage sys.path in wsgi.py. 不要在wsgi.py中管理sys.path。 Your file wsgi.py should be like 您的文件wsgi.py应该类似于

from pyramid.paster import get_app, setup_logging
configFile = 'D:\myproject\hello\develoment.ini'
setup_logging(configFile)
application = get_app(configFile, 'main')

Before running mod_wsgi, run the python interpreter you used to install pyramid and import pyramid code. 在运行mod_wsgi之前,请运行用于安装金字塔和导入金字塔代码的python解释器。 If that raises ImportError you either use wrong python interpreter or there is no pyramid installed. 如果这引起ImportError,则您使用了错误的python解释器,或者未安装金字塔。

from pyramid.paster import get_app, setup_logging

An excerpt from the configuration shown at mod_wsgi tutorial . 摘自mod_wsgi教程中显示的配置。

WSGIDaemonProcess pyramid user=chrism group=staff threads=4 \
   python-path=/your/path/to/python/lib/python2.X/site-packages
WSGIScriptAlias /myapp /your/path/to/project/pyramid.wsgi

Try starting with pyramid scaffolds to learn basic principles of pyramid applications. 尝试从金字塔脚手架开始学习金字塔应用的基本原理。 There is also detailed instruction about running pyramid on windows . 还有关于在Windows上运行金字塔的详细说明。

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

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