首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PyLaTeX教程生成错误:[WinError 2]

PyLaTeX教程生成错误:[WinError 2]
EN

Stack Overflow用户
提问于 2016-07-18 03:04:55
回答 1查看 935关注 0票数 2

我正在尝试在Python3.5中运行一个tutorial for PyLaTeX。我正在使用Anaconda / Spyder。当它运行命令"generate_pdf()“时,会生成WinError 2。下面是代码(这是正确的注解)和错误。简单地看一下链接可能会更容易。

代码语言:javascript
复制
def fill_document(doc):
    with doc.create(Section('A section')):
        doc.append('Some regular text and some ')
        doc.append(italic('italic text. '))

        with doc.create(Subsection('A subsection')):
            doc.append('Also some crazy characters: $&#{}')
             if __name__ == '__main__':
    # Basic document
    doc = Document('basic')
    fill_document(doc)
    doc.generate_pdf(filepath = r'C:\Users\James\Documents\Important Files\Python Scripts\PyLaTeX',clean_tex=False)

错误:

代码语言:javascript
复制
Traceback (most recent call last):

  File "<ipython-input-14-0158fa80c4f1>", line 1, in <module>
    runfile('C:/Users/James/Documents/Important Files/Python Scripts/PyLaTeX/basic_tutorial.py',
wdir='C:/Users/James/Documents/Important Files/Python
Scripts/PyLaTeX')

  File
"C:\Users\James\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
line 714, in runfile
    execfile(filename, namespace)

  File
"C:\Users\James\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
line 89, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/James/Documents/Important Files/Python
Scripts/PyLaTeX/basic_tutorial.py", line 21, in <module>
    doc.generate_pdf(filepath = r'C:\Users\James\Documents\Important Files\Python Scripts\PyLaTeX',clean_tex=False)

  File
"C:\Users\James\Anaconda3\lib\site-packages\pylatex\document.py", line
203, in generate_pdf
    raise(os_error)

  File
"C:\Users\James\Anaconda3\lib\site-packages\pylatex\document.py", line
157, in generate_pdf
    stderr=subprocess.STDOUT)

  File "C:\Users\James\Anaconda3\lib\subprocess.py", line 629, in
check_output
    **kwargs).stdout

  File "C:\Users\James\Anaconda3\lib\subprocess.py", line 696, in run
    with Popen(*popenargs, **kwargs) as process:

  File "C:\Users\James\Anaconda3\lib\subprocess.py", line 950, in
__init__
    restore_signals, start_new_session)

  File "C:\Users\James\Anaconda3\lib\subprocess.py", line 1220, in
_execute_child
    startupinfo)

FileNotFoundError: [WinError 2] The system cannot find the file
specified

提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2018-02-08 23:01:20

我也遇到了完全相同的问题,但是目录中有一个.log文件。所以我查看了日志,最后几行显示没有找到一个名为lastpage.sty的包(我在Linux上),所以我只是使用apt再次下载了所有的latex包。

所以我认为,你也应该阅读日志文件,如果有类似的东西,那么去ctan (所有的软件包都在那里找到),并安装Windows所需的软件包。

希望这能帮上忙。

还可以尝试将document.generate_tex()放在document.generate_pdf(filepath="path/to/file", clean_tex=False)之前

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38424923

复制
相关文章

相似问题

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