Python 3.7 pdflatex filenotfounderror

发布于 2025-01-24 03:21:52 字数 459 浏览 0 评论 0原文

我在Windows 10上使用Pycharm 3.7使用Python 3.7。我有一个Tex文件,并且想生成一个带有PDFLATEX的PDF。

pdfl = PDFLaTeX.from_texfile('test.tex')
pdf, log, completed_process = pdfl.create_pdf(keep_pdf_file=True, keep_log_file=True)

我不断收到以下错误:filenotfounderror:[errno 2]没有这样的文件或目录:'c:\ users \ myusername \ appdata \ local \ local \ temp \ tmps48h0jgi \ file.pdf' 该程序试图在我的用户文件夹中的temp文件夹中找到某个file.pdf。 (Texlive和Texstudio也已安装并工作。)

我做错了什么?

谢谢。

I am using python 3.7 with PyCharm on Windows 10. I have a Tex file and want to generate a pdf with pdflatex.

pdfl = PDFLaTeX.from_texfile('test.tex')
pdf, log, completed_process = pdfl.create_pdf(keep_pdf_file=True, keep_log_file=True)

I keep receiving the following error: FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\myusername\AppData\Local\Temp\tmps48h0jgi\file.pdf'
The program tries to find a certain file.pdf in my user folder in a temp folder.
(Texlive and TexStudio is also installed and working.)

What am I doing wrong?

Thanks.

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

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

发布评论

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

评论(2

木緿 2025-01-31 03:21:53

我也遇到了这个错误,对我而言,上述解决方案不起作用。这是一个对我有用的解决方案:

pdfl = PDFLaTeX.from_texfile('test.tex')
pdfl.set_interaction_mode()  # setting interaction mode to None.
pdf, log, completed_process = pdfl.create_pdf(keep_pdf_file=True, keep_log_file=True)

虽然Debuggin我发现互动_mode是PDFLATEX的意外参数。因此,它无法创建file.pdf文件,然后无法找到它。当相互作用_mode不是时,未给出参数,并且解决了错误。

I had this error too and for me the above solution didn't work. Here is a solution that works for me:

pdfl = PDFLaTeX.from_texfile('test.tex')
pdfl.set_interaction_mode()  # setting interaction mode to None.
pdf, log, completed_process = pdfl.create_pdf(keep_pdf_file=True, keep_log_file=True)

While debuggin I found that the interaction_mode was an unexpected argument for pdflatex. It therefore failed to create the file.pdf file and was then unable to find it. When interaction_mode is None the argument is not given and the error is resolved.

自由如风 2025-01-31 03:21:53

只需指定.tex文件的位置即可。

 def tex_pdf():
    current_path = os.path.dirname(os.path.dirname(__file__))
    media_folder = os.path.join(current_path, 'media/')


    with open(f'{media_folder}tex/sometexfile.tex', 'w') as file:
        file.write('\\documentclass{article}\n')
        file.write('\\begin{document}\n')
        file.write('Hello Palo Alto!\n')
        file.write('\\end{document}\n')

    pdfl = PDFLaTeX.from_texfile(f'{media_folder}tex/sometexfile.tex')
    pdf = pdfl.create_pdf(keep_pdf_file=True, keep_log_file=False)

Just specify where your .tex file is located.

 def tex_pdf():
    current_path = os.path.dirname(os.path.dirname(__file__))
    media_folder = os.path.join(current_path, 'media/')


    with open(f'{media_folder}tex/sometexfile.tex', 'w') as file:
        file.write('\\documentclass{article}\n')
        file.write('\\begin{document}\n')
        file.write('Hello Palo Alto!\n')
        file.write('\\end{document}\n')

    pdfl = PDFLaTeX.from_texfile(f'{media_folder}tex/sometexfile.tex')
    pdf = pdfl.create_pdf(keep_pdf_file=True, keep_log_file=False)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文