使用win7在apache上设置mercurial时出错 - DLL加载失败

时间:2011-12-05 12:49:25

标签: python apache mercurial

我正在尝试设置Mercurial,在Windows7机器上通过Apache发布它。这些是我遵循的步骤:

  1. 已安装Mercurial mercurial-2.0.0-x86.msi
  2. 已安装的Apache服务器 - httpd-2.2.21-win32-x86-openssl-0.9.8r.msi
  3. 安装了Python python-2.6.1.msi
  4. 设置Apache以通过mod_wsgi使用Python - mod_wsgi-win32-ap22py26-3.3.so。到目前为止,Apache一直很好。
  5. 创建了一个名为D:\ hg \ scripts
  6. 的目录
  7. 在此处解压缩Mercurial附带的library.zip D:\ hg \ scripts \ library_hg
  8. 将模板目录从Mercurial复制到D:\ hg \ scripts \ library_hg \ templates
  9. 在D:\ hg \ hgrepos \ demo1
  10. 中设置演示存储库
  11. 创建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)
    
  12. 我的D:\ hg \ scripts \ hgweb.config如下所示:

    [web]
    style = coal
    
    [paths]
    / = D:/hgrepos/*
    
  13. 我对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>
    
  14. 当我尝试访问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.
    
  15. 我几乎不了解Python。我一直试图在各种论坛中找到这个错误的原因而没有成功。感谢有人能指出我正确的方向

2 个答案:

答案 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)
相关问题