简体   繁体   English

在TRACE上使用Mercurial时,这一次在Windows 2008 R2(64位)上,在“需求导入”中获取“ DLL加载失败”或python异常

[英]Getting either “DLL load failed” or python-exception in demandimport, when using mercurial on trac, this time on Windows 2008 R2, 64 bit

This question , asked in 2011, and on a different operating system (XP instead of WSRV2008R2) is someone having a very similar sounding problem, but the accepted solution is to go back to a now-ancient mercurial version 1.8. 这个问题是在2011年提出的,并且在不同的操作系统(XP而不是WSRV2008R2)上听起来很相似,但是公认的解决方案是返回到较古老的水银版本1.8。 I don't think that is a good answer in 2012. 我认为这不是2012年的好答案。

I'd like to know if there is a way to get Apache 2.2 and Trac 0.12, and Mercurial 2.2.2 working on windows, and all running under Apache. 我想知道是否有一种方法可以使Apache 2.2和Trac 0.12,以及Mercurial 2.2.2在Windows上运行,并且都在Apache下运行。 The problems I'm having seem to be Python programming-related, and related to Python's use, and Mercurial's use, of various zipped and unzipped module formats. 我遇到的问题似乎与Python编程有关,并且与各种压缩和未压缩模块格式的Python使用以及Mercurial使用有关。

  1. It seems that to get this all working, may require you to build mercurial from sources, on windows, or to use Mercurial's "pure python" version. 似乎要使所有这些正常工作,可能需要您在Windows上从源代码构建Mercurial,或使用Mercurial的“纯python”版本。 I'd like to know what about Python, or what about Mercurial, leads to these problems which might need me to run "pure python". 我想知道Python或Mercurial会导致这些问题,这些问题可能需要我运行“纯python”。 Perhaps one accepted answer is that Mercurial is a quirky beast, and under mod_wsgi, one should use the pure python version of mercurial only. 也许一个公认的答案是Mercurial是一种古怪的野兽,在mod_wsgi下,应该只使用纯Python版本的mercurial。 The underlying Python and mercurial implementation reasons why, would be great to know, as well. 底层的Python和软件实现的原因也很重要。

  2. It seems that Mercurial's shady looking demand-loading feature is implicated, which is a source-code level feature in the mercurial sources, which is confusing me, and I'm hoping someone can explain it. 似乎暗示了Mercurial的幕后需求加载功能,这是Mercurial源码中的源代码级功能,这使我感到困惑,我希望有人能对此进行解释。

  3. The use in mercurial installed versions of a "library.zip" seems also to be creating an at-runtime situation where mercurial will import when I run python.exe from the command line (command prompt in Windows, with environment and path set as it would be set, if I was inside apache), but where Mercurial's primary python units will not import, from inside apache, with mod_wsgi. 在Mercurial已安装版本中使用“ library.zip”似乎也造成了运行时的情况,当我从命令行运行python.exe(Windows中的命令提示符,设置了环境和路径)时,Mercurial将导入(如果我在apache中,则将被设置),但是Mercurial的主要python单元不会使用mod_wsgi从apache中导入。

Here is the test script which I use which works fine, from a command prompt, and shows that this python 2.6 instance has a workable set of Mercurial stuff in site-packages : 这是我使用的测试脚本,在命令提示符下工作正常,并显示此python 2.6实例在site-packages具有一组可行的Mercurial内容:

from mercurial import ui, hg
path = 'D:/MyHgRepo'
repo = hg.repository(ui.ui(), path)
print path,"Repository info:"
print repr(repo), "object len: ",len(repo)

However, when running from within Trac which is hosted inside Apache , attempts to load the mercurial module fails, first with a strange demandimport failure, and when that is fixed, silently with no reason given in Trac (I'll have to debug in trac sourcecode to solve this last bit, perhaps). 但是,当从Apache内托管的Trac内部运行时,尝试加载Mercurial模块的尝试失败,首先是由于一个奇怪的demandimport失败,并且在修复该问题时,无故默默地在Trac中给出了原因(我将不得不在trac中进行调试)解决此问题的源代码,也许)。 Demandimport.py is a module inside the site-packages/Mercurial folder. Demandimport.py是site-packages / Mercurial文件夹中的一个模块。 This exception traceback comes from the trac.log: 此异常回溯来自trac.log:

In both cases, it says Look in the Trac log for more information. 在这两种情况下,它都会Look in the Trac log for more information. -- the error message here seems to be the problem: -这里的错误消息似乎是问题所在:

Traceback (most recent call last):
  File "build\bdist.win32\egg\trac\loader.py", line 68, in _load_eggs
    entry.load(require=True)
  File "build/bdist.linux-i686/egg/pkg_resources.py", line 1954, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "C:\Program Files\BitNami Trac Stack\python\lib\site-packages\mercurial\demandimport.py", line 114, in _demandimport
    mod = _origimport(name, globals, locals)
  File "build\bdist.win32\egg\trac\mimeview\rst.py", line 155, in <module>
  File "C:\Program Files\BitNami Trac Stack\python\lib\site-packages\mercurial\demandimport.py", line 87, in __getattribute__
    return getattr(self._module, attr)
AttributeError: 'module' object has no attribute 'directives'

The above exception can be fixed, oddly enough by "commenting out" that whole demand import unit. 上述异常可以通过“注释掉”整个需求导入单元来解决,这很奇怪。 Here's my null "pass" implementation: 这是我的空“ pass”实现:

# demandimport.py - disabled by warren.

'''
demandimport - disabled in code by warren.
'''

def enable():
    "does nothing"
    pass

def disable():
    "does nothing"
    pass 

The above hack clears up the above visible exception, leaving trac.log free of errors, and yet, still there is no Hg plugin visible inside Trac. 上面的hack清除了上面可见的异常,使trac.log中没有错误,但是,Trac中仍然没有可见的Hg插件。

From googling-wildly around the internet, I have found that: 通过互联网上的谷歌搜索,我发现:

  1. Mercurial installers for Windows that install into the \\Python2.6 system folder, ship a "Library.zip" that contains not only .pyc but also .pyd files. 安装到\\ Python2.6系统文件夹中的Windows的Mercurial安装程序附带一个“ Library.zip”,其中不仅包含.pyc,还包含.pyd文件。 This appears to work for some people, and fail for some people, when using mod_wsgi under apache, instead of while using Python interactively, or via standalone http hg serve operation. 当在apache下使用mod_wsgi而不是交互式使用Python或通过独立的http hg serve操作时,这似乎对某些人有效,而对某些人无效。 I have seen the author of the Trac Mercurial Plugin suggest unpacking library.zip. 我已经看到Trac Mercurial插件的作者建议拆包library.zip。 This is my first question; 这是我的第一个问题; What is going on with Library.zip and is it my problem. Library.zip是怎么回事,这是我的问题。

  2. Lots of people have a hard time getting Python 2.6 or 2.7, mod_wsgi, Trac, and Mercurial to all run from inside Apache, on Windows. 很多人很难在Windows上从Apache内部运行Python 2.6或2.7,mod_wsgi,Trac和Mercurial。 The underlying problems they have appear to be far beyond a software-user and installer's ability to solve, and require some arcane, or at least rudimentary python programming knowledge to solve. 它们的潜在问题似乎远远超出了软件用户和安装人员的解决能力,并且需要一些奥术,或者至少是基本的python编程知识来解决。

That is why I'm asking this question here, on a programming answers site. 这就是为什么我在编程答案网站上问这个问题的原因。 I want to understand Python, and its library and module and site-packages architecture, as used by the popular open source packages Mercurial, Trac, and others, so that I can understand, diagnose and debug the broken Python codebase of Mercurial 2.2, which does not function on my system, when used in the mod_wsgi/apache2.2 environment. 我想了解Python,以及流行的开源软件包Mercurial,Trac等使用的Python及其库,模块和站点软件包的体系结构,以便可以理解,诊断和调试Mercurial 2.2损坏的Python代码库,在mod_wsgi / apache2.2环境中使用时,在我的系统上不起作用。

I'm using Python 2.6, and Trac 0.12, all of which were installed by the Bitnami Trac Stack installer. 我正在使用Python 2.6和Trac 0.12,它们都是由Bitnami Trac Stack安装程序安装的。 I'm using Mercurial 2.2 installed via the mercurial-2.2-for-x86-for-Python2.6 installer from the mercurial website. 我正在使用通过Merurial网站上的mercurial-2.2-for-x86-for-Python2.6安装程序安装的Mercurial 2.2。

This happens because the version of Mercurial installed with binaries including some CPython extensions, that could not be imported into the version of Python that is being used inside the web server WSGI or CGI or other Python-in-apache technique. 发生这种情况是因为安装了带有二进制文件(包括一些CPython扩展名)的Mercurial版本无法导入到Web服务器WSGI或CGI或其他Python-in-apache技术内部使用的Python版本中。

Solution: 解:

A. Find and install the correct version of mercurial binaries (including the library.zip and CPython binary extensions used by Mercurial) A.查找并安装正确版本的Mercurial二进制文件(包括Mercurial使用的library.zip和CPython二进制扩展名)

B. Go for a pure 100%-python (no CPython binary extensions) version of Mercurial, such as hackable mercurial: B.选择Mercurial的纯100%-python(无CPython二进制扩展名)版本,例如可破解的mercurial:

https://www.mercurial-scm.org/wiki/HackableMercurial https://www.mercurial-scm.org/wiki/HackableMercurial

暂无
暂无

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

相关问题 在trac上使用mercurial时“DLL加载失败” - “DLL load failed” when using mercurial on trac python无法在64位Windows上加载64位DLL - python failed to load 64 bit DLL on a 64 bit Windows Python pylab ImportError:DLL加载失败Windows 7 64位 - Python pylab ImportError: DLL load failed Windows 7 64 Bit 导入cv2:ImportError:DLL加载失败:Windows 7 Anaconda 4.3.0(64位)Python 3.6.0 - Import cv2: ImportError: DLL load failed: windows 7 Anaconda 4.3.0 (64-bit) Python 3.6.0 Windows 10,Python 3.6和64位上的Tensorflow的DLL加载失败 - DLL load failed for Tensorflow on Windows 10, Python 3.6 and 64-bit 导入CV2:DLL加载失败(Windows 64位中的Python) - Import CV2: DLL load failed (Python in Windows 64bit) 在IIS7 64位上安装Mercurial时出错:“ DLL加载失败:%1不是有效的Win32应用程序” - Error while installing Mercurial on IIS7 64bit: “DLL Load Failed: %1 is not a valid Win32 application” Tensorflow(1.13.1)导入时出现异常:DLL加载失败(Windows 10) - Tensorflow (1.13.1) Exception when import: DLL load failed (Windows 10) win10 pro 64 bit + python 3.6.0 ImportError: DLL load failed: The specified module could not be found - win10 pro 64 bit + python 3.6.0 ImportError: DLL load failed: The specified module could not be found ImportError:DLL加载失败:操作系统无法运行%1。 Python 2.7.12 | Anaconda 4.2.0(64位) - ImportError: DLL load failed: The operating system cannot run %1. Python 2.7.12 |Anaconda 4.2.0 (64-bit)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM