【问题标题】:Hooking into mercurial pretxncommit. And can't import requests module?挂钩到 mercurial pretxncommit。并且不能导入请求模块?
【发布时间】:2013-02-21 10:36:03
【问题描述】:

您好,我正在尝试连接到 mercurial pretxncommit python 文件。
我的大部分代码都可以正常工作,但出现此错误:

错误:pretxncommit.pcrcheck 钩子引发异常:没有模块 命名请求事务中止! 回滚完成中止:没有名为请求的模块!

我正在尝试使用requests.getimport requests 在我制作的另一个独立 python 文件中运行良好,但似乎将其挂接到 mercurial 会导致无法导入此模块的问题。
这可能吗?

【问题讨论】:

标签: python mercurial commit pre-commit-hook


【解决方案1】:

所以我最终不得不添加所有这些哈哈。您必须将外部包的路径添加到 Mercurial 正在使用的路径上。(http://tortoisehg.bitbucket.io/manual/2.9/faq.html) 是的,看起来它们都是使requests module 工作所必需的,没有它们,我不断收到不同的导入错误。

这是我添加的内容:

import sys
sys.path.append(r'C:\\Python27\\Lib\\site-packages\\')
sys.path.append(r'C:\\Python27\\Lib\\')
sys.path.append(r'C:\\Python27\\Lib\\site-packages\\requests-1.1.0-py2.7.egg\\')
sys.path.append(r'C:\\Python27\\Lib\\site-packages\\simplejson-3.1.0-py2.7.egg\\simplejson')
sys.path.append(r'C:\\Python27\\Lib\\site-packages\\simplejson-3.1.0-py2.7.egg\\')
sys.path.append(r'C:\\Python27\\Lib\\site-packages\\simplejson-3.1.0-py2.7.egg\\simplejson\\tests\\')

【讨论】:

  • 这很烦人 :( 但看起来没有别的办法了!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-07-08
  • 1970-01-01
  • 2010-10-31
  • 2017-10-28
  • 2021-10-28
  • 1970-01-01
  • 2015-12-14
相关资源
最近更新 更多