Skip to main content
 首页 » 编程设计

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

2025年05月04日21bluestorm

我正在尝试设置 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. 将Mercurial自带的library.zip解压到D:\hg\scripts\library_hg
  7. 将模板目录从 Mercurial 复制到 D:\hg\scripts\library_hg\templates
  8. 在 D:\hg\hgrepos\demo1 中设置一个演示库
  9. 创建一个 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) 
    
  10. 我的 D:\hg\scripts\hgweb.config 看起来像:

    [web] 
    style = coal 
     
    [paths] 
    / = D:/hgrepos/* 
    
  11. 我的 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> 
    
  12. 当我尝试访问 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 几乎一无所知。我一直试图在各种论坛上找到这个错误的原因,但没有成功。感谢有人能指出我正确的方向

请您参考如下方法:

在花了几天时间试图找出解决方案后放弃。 我也曾尝试为 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。