我正在尝试在Python3.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提前谢谢。
发布于 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)之前
https://stackoverflow.com/questions/38424923
复制相似问题