【问题标题】:Install TortoiseHg for mac : No module named mercurial为 mac 安装 TortoiseHg:没有名为 mercurial 的模块
【发布时间】:2013-01-06 14:44:18
【问题描述】:

我正在尝试按照以下说明安装 TortoiseHg for Mac:https://bitbucket.org/tortoisehg/thg/wiki/developers/MacOSX#!alternative-install-via-macports

我正在尝试按照“替代方案:通过 Homebrew 安装”的说明进行操作,但遇到了问题。

当我按照说明执行./thg log 时,TortoiseHg 正在启动。但是,当我尝试从 python 脚本创建应用程序时,该应用程序已创建,但当我启动它时它会崩溃。

这是输出:

Traceback (most recent call last):
  File "/Users/fabienhenon/Documents/thg-mac-app/dist/TortoiseHg.app/Contents/Resources/__boot__.py", line 316, in <module>
    _run()
  File "/Users/fabienhenon/Documents/thg-mac-app/dist/TortoiseHg.app/Contents/Resources/__boot__.py", line 311, in _run
    exec(compile(source, path, 'exec'), globals(), globals())
  File "/Users/fabienhenon/Documents/thg-mac-app/dist/TortoiseHg.app/Contents/Resources/main.py", line 28, in <module>
    imp.load_source("thg", SCRIPT_DIR + "/bin/thg")
  File "/Users/fabienhenon/Documents/thg-mac-app/dist/TortoiseHg.app/Contents/Resources/bin/thg", line 56, in <module>
    from mercurial import demandimport
ImportError: No module named mercurial
2013-01-06 12:25:17.436 TortoiseHg[406:707] TortoiseHg Error
logout

[Opération terminée]

当我输入:hg --version 我有以下输出:

Mercurial Distributed SCM (version 2.4.2+20130102)
(see http://mercurial.selenic.com for more information)

Copyright (C) 2005-2012 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

有人可以帮我解决这个问题吗?

感谢您的回答

【问题讨论】:

  • 如果你想要它用于 mercurial,我建议你使用 SourceTree,我使用它,我对它非常满意。
  • @ipinak 我在另一台 Mac 上使用了 SourceTree,但每次推送某些内容时它都会在存储库中造成损坏。 Hpefully 我可以访问这个存储库,我可以修复它,但现在它用于 bitbucket 上的存储库主机,我害怕得到同样的错误:(这就是我试图在 mac 上获取 TortoiseHg 的原因
  • @FabienHenon 我没有答案,但如果找到答案,它对我也很有用。我在 Mac 上使用 TortoiseHg。我试图让它作为一个应用程序运行,但无法让它运行。相反,我只是从命令行运行它。
  • 我认为 Mac 上没有 TortoiseHg 的简单包很荒谬。所有的 Mac 替代品都很糟糕。

标签: python mercurial python-2.7 tortoisehg


【解决方案1】:

我找到了解决这个问题的方法。

根据我收到的错误消息,脚本找不到名为 mercurial 的模块。我是 Python 新手,所以我必须进行一些研究以了解模块导入的工作原理,并且我发现了一些关于使用 'sys' 模块动态导入模块的信息。

我的解决方案是编辑 tortoisehg 源代码(错误来自的文件)以将我的 mercurial 模块的路径动态添加到 'sys.path',以便程序知道在哪里可以找到 mercurial 模块。

这是代码(在“thg”python 文件中,第 56 行(如错误所述)):

import sys
sys.path.append("/Library/Python/2.7/site-packages")

您必须在此行之前添加此代码:

from mercurial import demandimport

并且路径必须与您的 mercurial 文件夹的位置相对应。

【讨论】:

    猜你喜欢
    • 2019-06-24
    • 1970-01-01
    • 2011-06-17
    • 1970-01-01
    • 2018-03-28
    • 1970-01-01
    • 2018-10-10
    • 2018-01-05
    • 2020-10-01
    相关资源
    最近更新 更多