' pdflatex'在捆绑的Pyinstaller应用程序中未发现

发布于 2025-02-04 10:49:16 字数 1324 浏览 5 评论 0 原文

我正在尝试使用。除了使用 pylatex )。

Pylatex pdflatex 模块都需要调用 subprocess 模块,如下所示:

fp = subprocess.run(args, input=self.latex, env=env, timeout=15, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

where args = ['pdflatex','-output-directory =/uders/udse/desktop','-sintaction mode = batchmode',' - - jobname = test']

但是,这在捆绑的应用程序中不起作用,因为它遇到了以下错误,我将登录到文件:

[Errno 2] No such file or directory: 'pdflatex' 

显然, pdflatex discarboble均未执行包含/发现在捆绑包中。在终端输出中运行哪个pdflatex 以下目录:/library/tex/texbin/pdflatex ,因此我尝试使用以下pyinstaller命令添加路径:

pyinstaller --noconsole --onefile --path "/Library/TeX/texbin" main.py

但是应用程序应用程序。仍然找不到 pdflatex 在运行时可执行的,而终端可执行文件无问题。我已经用尽了所有类似的帖子在线上,并且无法尝试尝试,所以我希望有人可以指导我采取解决方案。

相关信息:

  • MACOS版本:10.13.6 High Sierra
  • Python:3.8
  • Pyinstaller:5.1

I am attempting to create a macOS standalone app from a PyQt5 GUI using PyInstaller. All works apart from automatically generating a PDF from a TEX file using the pdflatex module (in conjunction with Pylatex).

Both the pylatex and pdflatex modules require calling the subprocess module, which is done as following:

fp = subprocess.run(args, input=self.latex, env=env, timeout=15, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

Where args=['pdflatex', '-output-directory=/Users/Desktop', '-interaction-mode=batchmode', '-jobname=test']

This however does not work within the bundled app as it is crashing with the following error which I am logging to a file:

[Errno 2] No such file or directory: 'pdflatex' 

Evidently, the pdflatex executable isn't being included/ found in the bundle. Running which pdflatex in the terminal outputs the following directory: /Library/TeX/texbin/pdflatex So I have tried to add the path with the following PyInstaller command:

pyinstaller --noconsole --onefile --path "/Library/TeX/texbin" main.py

But the app still cannot find the pdflatex executable at runtime, whereas the terminal executable works without issues. I have exhausted all similar posts online and ran out of things to try so I was hoping someone might guide me to the solution.

Related info:

  • macOS version: 10.13.6 High Sierra
  • Python: 3.8
  • PyInstaller: 5.1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑脸一如从前 2025-02-11 10:49:16

我遇到了同样的问题,我只是通过编辑Pyinstaller生成的运行时环境来解决它。在我的情况下,找不到 npm 命令,在运行之后,终端中的哪个NPM 可以看到NPM位于/usr/usr/usr/local/bin ,Pyinstaller在MacOS上未包含的路径。

因此,我的解决方案是在应用启动下运行此问题:

local_bin = '/usr/local/bin'
if local_bin not in os.environ["PATH"]:
   os.environ["PATH"] += os.pathsep + local_bin

I had the same problem and I just solved it by editing the runtime environment generated by PyInstaller. In my case the npm command was not found and after running which npm in terminal I could see that npm was located in /usr/local/bin, path that is not included by PyInstaller on macOS.

So my solution is to run this at app startup:

local_bin = '/usr/local/bin'
if local_bin not in os.environ["PATH"]:
   os.environ["PATH"] += os.pathsep + local_bin
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文