python - 使用 pyinstaller 的备用/tmp 位置

标签 python bash pyinstaller

我有一个 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/

相关文章:

python - 将多个列合并为单个列,并以列名作为值

python - 用 python 进行 sentiwordnet 评分

bash - 设置-eu时未绑定(bind)变量不会导致从子shell退出

python - 为什么 Pandas read_excel 函数在 Pyinstaller .exe 中返回错误,但在 Python 解释器下却没有?

python - 使用来自 appengine-utilities 的 session 在 Windows 上出错

python - 调用 Django i18n makemessages 命令时出现 UnicodeError 错误

linux - 为什么 '' var=value echo $var'' 不发出值?

bash - 如何在 Macbook 上为 oh-my-zsh 更改我的 $PS1?

python - pyinstaller错误: OSError: Python library not found: libpython3. 4mu.so.1.0, libpython3.4m.so.1.0, libpython3.4.so.1.0

python - 使用 PyInstaller 制作的 pyOpenGL exe 给出属性错误