python导入似乎在mercurial_keyring.py文件中表现不同 [英] python import seems to behave differently in mercurial_keyring.py file

查看:392
本文介绍了python导入似乎在mercurial_keyring.py文件中表现不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

奇怪的 import 错误阻止我安装mercurial扩展程序。

A bizarre import error is preventing me from installing a mercurial extension.

我正试图获取运行 mercurial_keyring 扩展程序,这样我每次使用mercurial进行项目时都不必输入我的用户名和密码。

I'm trying to get the mercurial_keyring extension running so that I don't have to type in my user name and password every time I use mercurial for a project.

我正在使用Python 2.7.1。我使用 https://www.mercurial-scm.org/ 提供的二进制文件安装了mercurial。

I'm using Python 2.7.1. I installed mercurial with the binary provided at https://www.mercurial-scm.org/.

我用<$ c安装密钥环 mercurial_keyring $ c> pip 。

I installed keyring and mercurial_keyring with pip.

我首先尝试添加扩展程序,将其添加到〜/ .hgrc

I first tried to add the extension by adding this to ~/.hgrc:

[extensions]
...
mercurial_keyring = 

如安装说明中所示这里。但是,我收到以下错误:

as indicated in the installation instructions here. However, I got the following error:

*** failed to import extension mercurial_keyring: No module named mercurial_keyring

从相同的安装说明中,我尝试将mercurial直接指向 mercurial_keyring.py 文件,有效。

From the same installation instructions, I tried pointing mercurial directly to the mercurial_keyring.py file, which worked.

[extensions]
...
hgext.mercurial_keyring = /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial_keyring.py

似乎有些事情

然而,当我尝试执行任何需要我的密码的mercurial命令时,它将被 keyring 例如 hg pull hg push )我收到错误

However, when I try to execute any mercurial commands requiring my password so that it will be saved by keyring (e.g. hg pull, hg push) I get the error

abort: No module named keyring!

最令人困惑的部分是有一个明确的

The most confusing part is that there is a clear

import keyring

在第28行 mercurial_keyring.py 已经解决,没有任何问题。事实上,任何导入密钥环都会在外部类和方法之外成功并在其中失败!

in line 28 of mercurial_keyring.py that is resolved without any problems. In fact, any import keyring succeeds outside classes and methods and fails inside them!

仅仅是为了彻底,我会提到中的密码存储中的 mercurial_keyring.py 中出现此错误c> get_http_password 尝试以下操作时的方法

Just for the sake of thoroughness, I'll mention that this error arises in the mercurial_keyring.py in the PasswordStore class in the get_http_password method when the following is attempted

return keyring.get_password(...)

有什么想法吗?

我有这种感觉我错过了一些明显的东西,但是我花了很多时间试图解决这个问题,到目前为止谷歌并没有特别有用。任何输入都将非常感激。

I have the feeling that I'm missing something obvious, but I've spent a good deal of time trying to figure this out and google has not been particularly helpful so far. Any input will be greatly appreciated.

推荐答案

最有可能的是, hg 是使用系统python(2.6)而不是你已经安装的2.7的副本运行。

Most likely, hg is running using the system python (2.6) rather than the copy of 2.7 you have installed.

尝试安装 mercurial_keyring 和2.6以下的密钥环,看看是否能按预期工作。

Try installing mercurial_keyring and keyring under 2.6, and see if that gets things working as expected.

这篇关于python导入似乎在mercurial_keyring.py文件中表现不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆