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

时间:2016-07-17 19:04:55

标签: latex python-3.5

我正在尝试在Python 3.5中运行tutorial for PyLaTeX。我正在使用Anaconda / Spyder。当它运行命令“generate_pdf()”时,会生成[WinError 2]。下面是代码(正确引用)和错误。单纯查看链接可能更容易。

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)

错误:

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

提前致谢。

1 个答案:

答案 0 :(得分:0)

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

所以我认为,您也应该阅读日志文件,如果有类似内容,请转到ctan(在那里找到所有软件包)并安装Windows所需的软件包。

希望它有所帮助。

同时尝试将apt放在document.generate_tex()

之前