我试图在windows系统上实现keyring,以管理pyodbc和sqlalchemy中连接字符串的数据库密码.我已尝试确保已安装抛出的NameError中的相关软件包.
这是我运行的代码:`
from keyring.backends import Windows
import keyring
keyring.set_keyring(Windows.WinVaultKeyring())
keyring.get_password("Service", "Username")
以下是引发的错误:
Traceback (most recent call last):
File ".\Python310\lib\site-packages\keyring\backends\Windows.py", line 109, in _get_password
res = win32cred.CredRead(
NameError: name 'win32cred' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".\Python310\lib\site-packages\keyring\core.py", line 55, in get_password
return get_keyring().get_password(service_name, username)
File ".\Python310\lib\site-packages\keyring\backends\Windows.py", line 99, in get_password
res = self._get_password(service)
File ".\Python310lib\site-packages\keyring\backends\Windows.py", line 112, in _get_password
except pywintypes.error as e:
NameError: name 'pywintypes' is not defined
已安装的软件包如下所示:
星体2.9.3回传字符集归一化器2.0.12密码学执行fsspec 2022.5.0 idna 3.3.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.1.0.0.0.1.0.0.0.0.0.0.0.0d>