Pyinstaller 密钥环 Windows 32 位
Pyinstaller Keyring Windows 32 bit
我有以下python测试代码:
import keyring
print(keyring.get_keyring())
keyring.set_password("a","b","c")
print(keyring.get_password("a","b"))
如果我 运行 此代码使用 32 位 python 或 64 位,我将获得以下输出(如预期):
<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"))
有效。
从 Keyring Github 页面设置 keyrings.alt 文件似乎确实有效,并且可以解释为什么这只是 Keyring>12 中的问题,因为它之前包含在模块中那。我还可以通过安装 pip install pywin32
和 运行 来解决这个问题:
import keyring
import win32timezone
from keyring.backends import Windows
keyring.set_keyring(Windows.WinVaultKeyring())
print(keyring.get_keyring())
keyring.set_password("a","b","c")
print(keyring.get_password("a","b"))
我有以下python测试代码:
import keyring
print(keyring.get_keyring())
keyring.set_password("a","b","c")
print(keyring.get_password("a","b"))
如果我 运行 此代码使用 32 位 python 或 64 位,我将获得以下输出(如预期):
<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"))
有效。
从 Keyring Github 页面设置 keyrings.alt 文件似乎确实有效,并且可以解释为什么这只是 Keyring>12 中的问题,因为它之前包含在模块中那。我还可以通过安装 pip install pywin32
和 运行 来解决这个问题:
import keyring
import win32timezone
from keyring.backends import Windows
keyring.set_keyring(Windows.WinVaultKeyring())
print(keyring.get_keyring())
keyring.set_password("a","b","c")
print(keyring.get_password("a","b"))