如何使 cx_freeze 可执行文件写入文本文件

How to make a cx_freeze executable write on a text file

我正在尝试制作一个 python 应用程序,我能够将我需要的文件夹放入构建文件夹中,但是每当 .exe 执行 open(SaveFile, "w") 命令时,我都会得到 PermissionError: [Errno 13] Permission denied. 这是我的 setup.py 代码:

import sys
from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need fine tuning.
# "packages": ["os"] is used as example only
build_exe_options = dict(include_files = ["IMG/", "Saves/"])

# base="Win32GUI" should be used only for Windows GUI app
base = None
if sys.platform == "win32":
    base = "Win32GUI"

setup(
    name = "PPD Mover",
    description = "An app to help move files for using PPD",
    options = {"build_exe": build_exe_options},
    executables = [Executable("File.py", base=base)]
)

我在读取文件时没有遇到任何错误,只是打开文件并在上面写入。 另外,我知道这可能是重复的,但我发现的唯一一个问题是 2 年多前上次活跃的,所以我想我可以问自己

编辑:我很笨,我之前读的东西不明白,我在评论中发布了我的解决方案,我会关闭这个问题,但我没有足够的声誉

我通过查看另一个 post 解决了它。如此处所述:CX_Freeze - Building a .msi with Admin permissions,它不应该写入随机文件夹中的文本文件,因此只需将其移动到 \AppData\Roaming 即可解决问题