python – Pyinstaller Keyring Windows 32位
作者:互联网
我有以下python测试代码:
import keyring
print(keyring.get_keyring())
keyring.set_password("a","b","c")
print(keyring.get_password("a","b"))
如果我使用32位python或64位python运行此代码,我将获得以下输出(如预期的那样):
<keyring.backends.Windows.WinVaultKeyring object at 0x00000187B7DD6358>
c
我的目的是构建两个独立的可执行文件(32位和64位):为了实现我使用pyinstaller和以下命令(test.py是包含上面显示的python代码的文件的名称)
pyinstaller --onefile test.py
如果我运行64位exe,我获得以下输出(如预期的那样):
<keyring.backends.Windows.WinVaultKeyring object at 0x00000187B7DD6358>
c
相反,如果我运行32位exe,我获得以下输出:
<keyring.backends.fail.Keyring object at 0x05463ED0>
Traceback (most recent call last):
File "test.py", line 3, in <module>
keyring.set_password("a","b","c")
File "site-packages\keyring\core.py", line 47, in set_password
File "site-packages\keyring\backends\fail.py", line 23, in get_password
RuntimeError: No recommended backend was available. Install the keyrings.alt package if you want to use the non-recommended backends. See README.rst for details.
[2732] Failed to execute script test
有谁知道发生了什么?
谢谢,
丹尼尔
解决方法:
使用备用密钥环后端解决.如果我更改我的代码:
import keyring
print(keyring.get_keyring())
keyring.set_password("a","b","c")
print(keyring.get_password("a","b"))
至:
import keyring
from keyrings.alt import Windows
keyring.set_keyring(Windows.RegistryKeyring())
print(keyring.get_keyring())
keyring.set_password("a","b","c")
print(keyring.get_password("a","b"))
有用.
标签:python,windows,32-bit,pyinstaller,python-keyring 来源: https://codeday.me/bug/20190705/1388544.html