首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python3.7 pdflatex filenotfounderror

Python3.7 pdflatex filenotfounderror
EN

Stack Overflow用户
提问于 2022-04-24 19:23:45
回答 1查看 246关注 0票数 2

我在Windows10上使用python3.7和PyCharm,我有一个Tex文件,我想用pdflatex生成一个pdf。

代码语言:javascript
复制
pdfl = PDFLaTeX.from_texfile('test.tex')
pdf, log, completed_process = pdfl.create_pdf(keep_pdf_file=True, keep_log_file=True)

我一直收到以下错误: FileNotFoundError: Errno 2,没有这样的文件或目录:FileNotFoundError,该程序试图在临时文件夹中的用户文件夹中找到特定的file.pdf。(Texlive和TexStudio也被安装和工作。)

我做错了什么?

谢谢。

EN

回答 1

Stack Overflow用户

发布于 2022-06-08 21:58:35

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

代码语言:javascript
复制
 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)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71991645

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档