我有一个 Python 脚本,然后我通过 pyinstaller2.0 运行它来生成它的二进制文件。
python pyinstaller -F /path/to/python/script
在运行二进制文件时,它默认使用/tmp 文件夹来保存它的临时文件并运行安装程序。这在普通服务器和 VPS 上运行良好。但是,在禁用/tmp (/tmp noexec
) 的服务器上尝试安装时,安装会失败。
我的问题如下:
- 运行二进制文件时如何启用另一个临时位置? pyinstaller 有这样的选项吗?
- 如果我编写代码来创建一个临时位置并将其导出到 python 脚本中的 PATH,它是否会尝试使用默认/tmp 来运行 python 二进制文件?
- 我想到的另一种方法是在 bash 中编写一个 shell 脚本,它创建一个临时位置,导出它的 PATH,然后调用 python 二进制文件,在它运行后,从 PATH 中删除临时位置,并删除临时文件夹- 但这似乎是一种迂回的方式来完成它。有更好的解决方案吗?
最佳答案
自 PyInstaller
V3.3 (2017-09-21)你可以使用--runtime-tmpdir更改默认提取路径的参数,即:
--runtime-tmpdir PATH
Where to extract libraries and support files in onefile-mode. If this option is given, the
bootloader
will ignore any temp-folder location defined by the run-time OS. The_MEIxxxxxx-folder
will be created here. Please use this option only if you know what you are doing.
关于python - 使用 pyinstaller 的备用/tmp 位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18841334/