gpt4 book ai didi

python - GnuPG homedir 读/写权限

转载 作者:太空宇宙 更新时间:2023-11-03 14:04:32 26 4
gpt4 key购买 nike

我正在尝试通过 Win7 上的 Python 脚本使用 GnuPG 解密 tar 文件。

filename_e_archive = askopenfilename()
current_directory = os.path.abspath('.')
folder_d_archive = filename_e_archive.split('.elog')[0]
filename_d_archive = folder_d_archive + ".tar.gz"
path_to_e_archive = os.path.dirname(filename_e_archive)
path_to_d_archive = os.path.join(path_to_e_archive,'/',folder_d_archive)
os.makedirs(path_to_d_archive)
os.chdir(path_to_d_archive)

gpg = gnupg.GPG()

with open(filename_e_archive, 'rb') as f:
status = gpg.decrypt_file(f, passphrase='mypassword',output=filename_d_archive)

运行时出现以下错误:

C:\LA>python test.py Traceback (most recent call last): File "test.py", line 30, in gpg = gnupg.GPG() File "C:\Python27\lib\site-packages\gnupg\gnupg.py", line 125, in init ignore_homedir_permissions=ignore_homedir_permissions, File "C:\Python27\lib\site-packages\gnupg_meta.py", line 183, in init self.homedir = os.path.expanduser(home) if home else _util._conf File "C:\Python27\lib\site-packages\gnupg_util.py", line 765, in set getattr(obj, self.fset.name)(value) File "C:\Python27\lib\site-packages\gnupg_meta.py", line 440, in _homedir_set ter raise RuntimeError(str(ae)) RuntimeError: Homedir ''C:\LA\gnupghome.config\python-gnupg'' needs read/write permissions

C:\LA>

最佳答案

我能够通过删除 gnupg 库解决该问题:

pip uninstall gnupg

并安装 phyton-gnupg

pip install python-gnupg

文档:python-gnupg - A Python wrapper for GnuPG

关于python - GnuPG homedir 读/写权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48998930/

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