我正在尝试设置Mercurial,在Windows7机器上通过Apache发布它。这些是我遵循的步骤:
创建D:\ hg \ scripts \ hgweb.config。来源:
# An example WSGI for use with mod_wsgi, edit as necessary
# An example WSGI for use with mod_wsgi, edit as necessary
# See https://www.mercurial-scm.org/wiki/modwsgi for more information
# Path to repo or hgweb config to serve (see 'hg help hgweb')
config = "D:/hg/scripts/hgweb.config"
# Uncomment and adjust if Mercurial is not installed system-wide:
import sys; sys.path.insert(0, "D:/hg/scripts/library_hg");
#print sys.path;
# Uncomment to send python tracebacks to the browser if an error occurs:
#import cgitb; cgitb.enable()
# enable demandloading to reduce startup time
#from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb import hgweb
application = hgweb(config)
我的D:\ hg \ scripts \ hgweb.config如下所示:
[web]
style = coal
[paths]
/ = D:/hgrepos/*
我对Apache httpd.conf的配置是:
WSGIScriptAlias /hg "D:/hg/scripts/hgweb.wsgi"
<Directory "D:/hg/hgrepos">
Order deny,allow
Allow from all
</Directory>
<Directory "D:/hg/scripts/">
Options ExecCGI FollowSymlinks
AddHandler wsgi-script .wsgi
AllowOverride None
Order allow,deny
Allow from all
</Directory>
当我尝试访问hg脚本http://localhost:9000/hg时,出现以下错误:
mod_wsgi (pid=3492): Target WSGI script 'D:/hg/scripts/hgweb.wsgi' cannot be loaded as Python module.
mod_wsgi (pid=3492): Exception occurred processing WSGI script 'D:/hg/scripts/hgweb.wsgi'.
Traceback (most recent call last):
File "D:/hg/scripts/hgweb.wsgi", line 17, in <module>
from mercurial.hgweb import hgweb
File "mercurial\\hgweb\\__init__.pyc", line 10, in <module>
File "mercurial\\hgweb\\hgweb_mod.pyc", line 10, in <module>
File "mercurial\\ui.pyc", line 8, in <module>
File "mercurial\\i18n.pyc", line 8, in <module>
File "mercurial\\encoding.pyc", line 9, in <module>
File "unicodedata.pyc", line 12, in <module>
File "unicodedata.pyc", line 10, in __load
ImportError: DLL load failed: The specified module could not be found.
我几乎不了解Python。我一直试图在各种论坛中找到这个错误的原因而没有成功。感谢有人能指出我正确的方向
答案 0 :(得分:1)
花费数天时间试图找出解决方案后放弃。 我也尝试过为windows创建mercurial但没有成功。
我从python shell运行了hgweb.wsgi中的相同命令,我没有得到DLL错误。我认为这个线程概述了python发行版中的问题而不是mercurial: http://groups.google.com/group/modwsgi/browse_thread/thread/fa72de2deef276d9
由于某种原因,运行apache和mod_wsgi的python无法在Windows中找到DLL。
答案 1 :(得分:0)
从https://www.mercurial-scm.org/downloads开始,您将下载Python 2.6软件包,并删除D:\ hg \ scripts \ library_hg目录,因为一旦安装此软件包就会浪费空间,您可以将导入sys系列注释掉好。
此外,在您的配置上,您需要[集合],而不是[路径](并且没有*)
可能不需要,但除了无法加载模块之外,您还会遇到错误,请使用以下内容替换hgweb.wsgi文件的最后两行:
from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb import hgweb, wsgicgi
application = hgweb(config)
wsgicgi.launch(application)