3

安装后我遇到了 python 密钥环的问题。这是我的步骤:

$ python
>>> import keyring
>>> keyring.set_password('something','otherSomething','lotOfMoreSomethings')

然后抛出这个:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/keyring/core.py", line 42, in set_password
   _keyring_backend.set_password(service_name, username, password)
File "/usr/local/lib/python2.6/dist-packages/keyring/backend.py", line 222, in set_password
   _, session = service_iface.OpenSession("plain", "")
File "/usr/lib/pymodules/python2.6/dbus/proxies.py", line 68, in __call__
   return self._proxy_method(*args, **keywords)
File "/usr/lib/pymodules/python2.6/dbus/proxies.py", line 140, in __call__
   **keywords)
File "/usr/lib/pymodules/python2.6/dbus/connection.py", line 630, in call_blocking
   message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod:
   Method "OpenSession" with signature "ss" on interface "org.freedesktop.Secret.Service" 
   doesn't exist

我已经从这里安装了钥匙圈

easy_install keyring

我做错什么了吗??有什么解决办法??

编辑:

我还从 repos 安装了 python-keyring 和 python-keyring-gnome 并像导入

>>> import gnome_keyring

和作品。

4

2 回答 2

0

如果使用 gnomekeyring python 包,您可以使用 item_create_sync 方法创建新密码条目或替换给定密钥的现有密码

#!/usr/bin/env python
import gnomekeyring

gnomekeyring.item_create_sync ("keyring-name", gnomekeyring.ITEM_GENERIC_SECRET, "key-display-name", {}, "password", True)

item_create_sync 方法签名在哪里

item_create_sync (string? keyring, ItemType type, string display_name, AttributeList attributes, string secret, bool update_if_exists)
于 2015-10-08T22:19:28.563 回答
0

我遇到了类似的问题,但我的 DBus 异常出现在 kwalletd(特别是 /modules/kwalletd)上,即使我使用 Gnome。

我的工作是创建一个本地“keyringrc.cfg”文件,如下所示:

[backend]
default-keyring=keyring.backends.Gnome.Keyring

请参阅Python 密钥环包以确定您的系统的配置文件路径的位置。

于 2016-02-23T04:12:35.553 回答