在启动PyLatex或Latexmk时如何隐藏命令提示符弹出窗口

Pav*_*l.D 7 python latex cmd python-3.x pylatex

如何隐藏启动和执行pylatex代码期间弹出的命令提示符。我有一个正在处理的页面并生成pdf。运行代码时,我需要隐藏弹出窗口。

谈论这个窗口:

在此处输入图片说明

有没有办法隐藏或不显示latexmk.exe弹出窗口?

我一直在搜寻和搜寻,但没有发现与此问题相关的内容。

D S*_*iro 2

查看了 Pylatex 的源代码后,我猜您可能正在使用的generate_pdf() 方法实际上允许使用silent=true/false 参数

来源评论:

silent: bool
    Whether to hide compiler output
Run Code Online (Sandbox Code Playgroud)

然而,这似乎并没有做很多事情,我相信如果您要传递该参数,您可能仍然会面临同样的问题,因为;

    else:
        if not silent:
            print(output.decode())
Run Code Online (Sandbox Code Playgroud)

似乎有两个单独的地方调用了 check_output(子进程方法)的使用来启动 Latexmk。这有助于您看到的窗口。

pylatest/document.py 行:

可能的解决方案

您可以通过传入额外参数 shell=True 对这两行进行调整,这将不会在调用 Latexmk 时显示 cmd 窗口。

         output = subprocess.check_output(command,
                                         stderr=subprocess.STDOUT,
                                         shell=True)
Run Code Online (Sandbox Code Playgroud)