我正在努力学习PyLatex.我已经通过pip安装它并从这里复制了基本代码,我遇到了这个问题:
C:\Conner\Scripts>pylatAttempt.py
latexmk: The script interpreter could not be found.
latexmk: Data: scriptInterpreter="perl.exe"
Traceback (most recent call last):
File "C:\Conner\Scripts\pylatAttempt.py", line 23, in <module>doc.generate_pdf()
File "C:\Python27\ArcGIS10.2\lib\site-packages\pylatex\document.py", line 193, in generate_pdf raise(e)
subprocess.CalledProcessError: Command '[u'latexmk', u'--pdf', u'--interaction=nonstopmode', u'basic.tex']' returned non-zero exit status 1
Run Code Online (Sandbox Code Playgroud)
我已经下载了MiKTeX 2.9,我还需要其他什么吗?这里出了什么问题?从文档看来,您需要安装的所有内容都是pylatex.
小智 5
您可以将编译器更改为pdflatex而不是latexmk,如果您已安装miktex和pdflatex,它将起作用.latexmk默认是编译器.
doc.generate_pdf(clean_tex=False,compiler='pdflatex')
Run Code Online (Sandbox Code Playgroud)
我正在使用Python 2.7.14 :: Anaconda, Inc.,当我第一次尝试执行https://jeltef.github.io/PyLaTeX/latest/examples/basic.html上提供的 PyLaTeX 示例时,我遇到了同样的问题。
1)当我在安装MikTeX之前执行复制的代码时
(pylatex) G:\RishikeshAgrawani\ProjectsWin7\Python3\PyLaTeX\pylatex\01_basic>python 01
Traceback (most recent call last):
File "01_basic.py", line 24, in <module>
doc.generate_pdf(clean_tex=False)
File "C:\Anaconda2.5.0.1\lib\site-packages\pylatex\document.py", line 317, in genera
u'or make sure you have latexmk or pdfLaTex installed.'
pylatex.errors.CompilerError: No LaTex compiler was found
Either specify a LaTex compiler or make sure you have latexmk or pdfLaTex installed.
Run Code Online (Sandbox Code Playgroud)
2) MikTeX安装后
您可以看到上面的输出,它正在寻找LaTex compiler我们可以通过安装MikTeX来安装的输出。
您可以在https://miktex.org/download下载MikTeX。
(C:\Anaconda2.5.0.1) G:\RishikeshAgrawani\ProjectsWin7\Python3\PyLaTeX\pylatex\01_basic>python 01_basic.py
latexmk: The script engine could not be found.
latexmk: Data: scriptEngine="perl.exe"
Traceback (most recent call last):
File "01_basic.py", line 24, in <module>
doc.generate_pdf(clean_tex=False)
File "C:\Anaconda2.5.0.1\lib\site-packages\pylatex\document.py", line 269, in generate_pdf
stderr=subprocess.STDOUT)
File "C:\Anaconda2.5.0.1\lib\subprocess.py", line 219, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '[u'latexmk', u'--pdf', u'--interaction=nonstopmode', u'basic.tex']' returned non-zero exit
status 1
Run Code Online (Sandbox Code Playgroud)
3)安装STARWBERRY PERL后
您可以看到上面的输出,它正在寻找perl.exe.
所以我从http://strawberryperl.com/下载了Strawberry perl并安装了它。
现在我成功运行了代码并得到了PDF。
(C:\Anaconda2.5.0.1) G:\RishikeshAgrawani\ProjectsWin7\Python3\PyLaTeX\pylatex\01_basic>python 01_basic.py
(C:\Anaconda2.5.0.1) G:\RishikeshAgrawani\ProjectsWin7\Python3\PyLaTeX\pylatex\01_basic>
Run Code Online (Sandbox Code Playgroud)
就是这样。
| 归档时间: |
|
| 查看次数: |
3827 次 |
| 最近记录: |