我在安装后遇到python keyring问题。 这是我的步骤:
$ 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
我已使用
从here安装了密钥环easy_install keyring
我做错了什么?有什么解决方案??
编辑:
我还从repos安装了python-keyring和python-keyring-gnome,只是像
那样导入>>> import gnome_keyring
并且有效。
答案 0 :(得分: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)
答案 1 :(得分:0)
我遇到了类似的问题,但即使我使用Gnome,我的DBus Exception也在kwalletd(特别是/ modules / kwalletd)上。
我的工作是创建一个本地&#34; keyringrc.cfg&#34;像这样的文件:
[backend]
default-keyring=keyring.backends.Gnome.Keyring
请参阅Python keyring Package以确定系统的Config文件路径的位置。