gpt4 book ai didi

python key 环,无法设置密码

转载 作者:行者123 更新时间:2023-11-28 19:26:00 27 4
gpt4 key购买 nike

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

$ 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 安装了 key 环使用

easy_install keyring

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

编辑:

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

>>> import gnome_keyring

并且有效。

最佳答案

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

#!/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)

关于python key 环,无法设置密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12993175/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com