python - Windows 10/11 上的 .exe 文件附带的文件存储在哪里?

标签 python exe nuitka

所以我制作了这个 python 文件,我想用 Nuitka 将其编译(称为 ElPatron)为 .exe 文件。 我做得正确,这是随之而来的 dist 文件夹(使用 Nuitka 的 --standalone 参数)

这是我使用的 nuitka 命令:

.\python.exe -m nuitka --mingw64 .\ElPatron.py --standalone --onefile --windows-disable-console --windows-icon-from-ico=pdf.ico --include-data-file=C:\Users\User\AppData\Local\Programs\Python\Python39\example.pdf=example.pdf

我使用 Nuitka 的 --include-data-file 参数将 pdf 包含在 exe 中

Dist folder that nuitka has created

我现在遇到的问题是,我不知道执行 ElPatron.exe 时这个(example.pdf)存储在哪里。我想知道这一点,以便我可以在我的 Python 项目中调用它。

问题

当 Windows 计算机执行 .exe(包含 pdf)时,example.pdf 存储在哪里?

最佳答案

查看Nuitka documentation ,它说:

# Create a binary that unpacks into a temporary folder
python -m nuitka --onefile program.py

Note

There are more platform specific options, e.g. related to icons, splash screen, and version information, consider the --help output for the details of these and check the section “Good Looks”.

Again, on Windows, for the temporary file directory, by default the user one is used, however this is overridable with a path specification given in --windows-onefile-tempdir-spec=%TEMP%\\onefile_%PID%_%TIME% which is the default and asserts that the temporary directories created cannot collide.

因此,我认为输出应按所述显示为 %TEMP% 中的子目录,该路径应为路径 C:\Users\%USERNAME%\AppData\Local\温度\.

如果您想使用默认路径,则必须在 中找到动态命名的子文件夹 (onefile_%PID%_%TIME%) >%TEMP% 在 Python 中,您可以 get the current process ID ,然后使用模糊模式或其他东西,因为您将无法知道确切的时间。否则,设置自定义路径。

关于python - Windows 10/11 上的 .exe 文件附带的文件存储在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70384301/

相关文章:

python - Python与Nuitka交叉编译到Windows失败

file - 较大的 .exe 文件无法删除自身,而较小的 .exe 文件可以使用相同的代码(Delphi)

c++ - 一种为在 bash 中调用的程序提供参数的方法

python - 如何在每个维度上调整体积图像的大小或形状?

python - python-mysql-connector 1.16、django 1.6 和 python 3.2.3 导入错误

.net - 使用 Assembly vs AppDomain 查找我的主要可执行文件的路径

linux - 为什么在尝试运行此可执行文件时出现错误?

python - 带有 zeroMQ 的 Nuitka

python - 使用循环创建和分配多个变量 (Python)

python - 在 Python 3 中从网站中查找最常用的词