首页 > 解决方案 > 无法使用 TeXStudio 编译 Minted 环境

问题描述

我正在写一个 Latex 文档,并希望有一些代码突出显示。所以我决定使用 minted 包。但我不能让最小的例子起作用。

Pygments 包通过 anaconda 安装在路径 /anaconda3/lib/python3.7/site-packages 下。从 CLI 运行 pygmentize -V 有效。

我正在使用 TexStudio,并且还在命令中包含了“-shell-escape”。

但无论如何我收到以下错误

line 94: Paragraph ended before \zap@space was complete....\edef\@tempa{\expandafter\zap@space\@tempa
line 104: Paragraph ended before \ip@only@six was complete. ...ef\@tempc{\expandafter\ip@only@six\@tempa
line 104: Undefined control sequence. ...expandafter\ip@only@six\@tempa------\@nil
line 5: Package minted Error: You must have `pygmentize' installed to use this package. \begin{document}
line 11: Package minted Error: Missing Pygments output; \inputminted wasor may be using frozencache with a missing file. \end{minted}^^M
line 11: Package minted Error: Missing Pygments output; \inputminted wasor may be using frozencache with a missing file. \end{minted}^^M
line 11: Package minted Error: Missing Pygments output; \inputminted wasor may be using frozencache with a missing file. \end{minted}

这个例子:

\documentclass{article}

\usepackage{minted}

\begin{document}
    \begin{minted}{c}
        int main() {
            printf("hello, world");
            return 0;
        }
    \end{minted}
\end{document}

操作系统是 macOS Mojave。

谁能告诉我发生了什么事?

更新:根据评论中的要求,这是完整的日志

This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=pdflatex 2019.10.21)  21 OCT 2019 16:34
entering extended mode
 \write18 enabled.
 %&-line parsing enabled.
**PraxisphaseAufsatz.tex
(./PraxisphaseAufsatz.tex
LaTeX2e <2019-10-01> patch level 1
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/08/27 v1.4j Standard LaTeX document class
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2019/08/27 v1.4j Standard LaTeX file (size option)
)
\c@part=\count80
\c@section=\count81
\c@subsection=\count82
\c@subsubsection=\count83
\c@paragraph=\count84
\c@subparagraph=\count85
\c@figure=\count86
\c@table=\count87
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
(/usr/local/texlive/2019/texmf-dist/tex/latex/minted/minted.sty
Package: minted 2017/07/19 v2.5 Yet another Pygments shim for LaTeX

(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks14
)
(/usr/local/texlive/2019/texmf-dist/tex/latex/oberdiek/kvoptions.sty
Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO)

(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/ltxcmds.sty
Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
)
(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO)

(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/infwarerr.sty
Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO)
)
(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/etexcmds.sty
Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)

(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/ifluatex.sty
Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO)
Package ifluatex Info: LuaTeX not detected.
))))
(/usr/local/texlive/2019/texmf-dist/tex/latex/fvextra/fvextra.sty
Package: fvextra 2019/02/04 v1.4 fvextra - extensions and patches for fancyvrb

(/usr/local/texlive/2019/texmf-dist/tex/latex/base/ifthen.sty
Package: ifthen 2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
)
(/usr/local/texlive/2019/texmf-dist/tex/latex/etoolbox/etoolbox.sty
Package: etoolbox 2019/09/21 v2.5h e-TeX tools for LaTeX (JAW)
\etb@tempcnta=\count88
)
(/usr/local/texlive/2019/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty
Package: fancyvrb 2019/01/15

Style option: `fancyvrb' v3.2a <2019/01/15> (tvz)
\FV@CodeLineNo=\count89
\FV@InFile=\read1
\FV@TabBox=\box27
\c@FancyVerbLine=\count90
\FV@StepNumber=\count91
\FV@OutFile=\write3
)
(/usr/local/texlive/2019/texmf-dist/tex/latex/upquote/upquote.sty
Package: upquote 2012/04/19 v1.3 upright-quote and grave-accent glyphs in verba
tim
)
(/usr/local/texlive/2019/texmf-dist/tex/latex/lineno/lineno.sty
Package: lineno 2005/11/02 line numbers on paragraphs v4.41
\linenopenalty=\count92
\output=\toks15
\linenoprevgraf=\count93
\linenumbersep=\dimen103
\linenumberwidth=\dimen104
\c@linenumber=\count94
\c@pagewiselinenumber=\count95
\c@LN@truepage=\count96
\c@internallinenumber=\count97
\c@internallinenumbers=\count98
\quotelinenumbersep=\dimen105
\bframerule=\dimen106
\bframesep=\dimen107
\bframebox=\box28
LaTeX Info: Redefining \\ on input line 3056.
)
\c@FV@TrueTabGroupLevel=\count99
\c@FV@TrueTabCounter=\count100
\FV@TabBox@Group=\box29
\FV@TmpLength=\skip43
\c@FV@HighlightLinesStart=\count101
\c@FV@HighlightLinesStop=\count102
\FV@LoopCount=\count103
\FV@NCharsBox=\box30
\FV@BreakIndent=\dimen108
\FV@BreakIndentNChars=\count104
\FV@BreakSymbolSepLeft=\dimen109
\FV@BreakSymbolSepLeftNChars=\count105
\FV@BreakSymbolSepRight=\dimen110
\FV@BreakSymbolSepRightNChars=\count106
\FV@BreakSymbolIndentLeft=\dimen111
\FV@BreakSymbolIndentLeftNChars=\count107
\FV@BreakSymbolIndentRight=\dimen112
\FV@BreakSymbolIndentRightNChars=\count108
\c@FancyVerbLineBreakLast=\count109
\FV@LineBox=\box31
\FV@LineIndentBox=\box32
\FV@LineWidth=\dimen113
)
(/usr/local/texlive/2019/texmf-dist/tex/latex/tools/calc.sty
Package: calc 2017/05/25 v4.3 Infix arithmetic (KKT,FJ)
\calc@Acount=\count110
\calc@Bcount=\count111
\calc@Adimen=\dimen114
\calc@Bdimen=\dimen115
\calc@Askip=\skip44
\calc@Bskip=\skip45
LaTeX Info: Redefining \setlength on input line 80.
LaTeX Info: Redefining \addtolength on input line 81.
\calc@Ccount=\count112
\calc@Cskip=\skip46
)
(/usr/local/texlive/2019/texmf-dist/tex/latex/tools/shellesc.sty
Package: shellesc 2016/06/07 v0.02b unified shell escape interface for LaTeX
Package shellesc Info: Unrestricted shell escape enabled on input line 70.
)
(/usr/local/texlive/2019/texmf-dist/tex/latex/ifplatform/ifplatform.sty
Package: ifplatform 2017/10/13 v0.4a Testing for the operating system

(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
Package: pdftexcmds 2019/07/25 v0.30 Utility functions of pdfTeX for LuaTeX (HO
)

(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/ifpdf.sty
Package: ifpdf 2018/09/07 v3.3 Provides the ifpdf switch
)
Package pdftexcmds Info: LuaTeX not detected.
Package pdftexcmds Info: \pdf@primitive is available.
Package pdftexcmds Info: \pdf@ifprimitive is available.
Package pdftexcmds Info: \pdfdraftmode found.
)
(/usr/local/texlive/2019/texmf-dist/tex/generic/oberdiek/catchfile.sty
Package: catchfile 2016/05/16 v1.7 Catch the contents of a file (HO)
)
runsystem(uname -s > "PraxisphaseAufsatz.w18")...executed.


(./PraxisphaseAufsatz.w18)
runsystem(rm -- "PraxisphaseAufsatz.w18")...executed.


Runaway argument?
! Paragraph ended before \zap@space was complete.
<to be read again> 
                   \par 
l.94 ...\edef\@tempa{\expandafter\zap@space\@tempa
                                                  \@empty}
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.

Runaway argument?
! Paragraph ended before \ip@only@six was complete.
<to be read again> 
                   \par 
l.104 ...ef\@tempc{\expandafter\ip@only@six\@tempa
                                                  ------\@nil}
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.

! Undefined control sequence.
l.104 ...expandafter\ip@only@six\@tempa------\@nil
                                                  }
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

) (/usr/local/texlive/2019/texmf-dist/tex/generic/xstring/xstring.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/xstring/xstring.tex
\integerpart=\count113
\decimalpart=\count114
)
Package: xstring 2019/02/06 v1.83 String manipulations (CT)
)
(/usr/local/texlive/2019/texmf-dist/tex/latex/framed/framed.sty
Package: framed 2011/10/22 v 0.96: framed or shaded text with page breaks
\OuterFrameSep=\skip47
\fb@frw=\dimen116
\fb@frh=\dimen117
\FrameRule=\dimen118
\FrameSep=\dimen119
)
(/usr/local/texlive/2019/texmf-dist/tex/latex/float/float.sty
Package: float 2001/11/08 v1.3d Float enhancements (AL)
\c@float@type=\count115
\float@exts=\toks16
\float@box=\box33
\@float@everytoks=\toks17
\@floatcapt=\box34
)
\minted@appexistsfile=\read2
\minted@bgbox=\box35
\minted@code=\write4
\c@minted@FancyVerbLineTemp=\count116
\c@minted@pygmentizecounter=\count117
\@float@every@listing=\toks18
\c@listing=\count118
)
runsystem(mkdir -p _minted-PraxisphaseAufsatz)...executed.


(/usr/local/texlive/2019/texmf-dist/tex/latex/xcolor/xcolor.sty
Package: xcolor 2016/05/11 v2.12 LaTeX color extensions (UK)

(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics-cfg/color.cfg
File: color.cfg 2016/01/02 v1.6 sample color configuration
)
Package xcolor Info: Driver file: pdftex.def on input line 225.

(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics-def/pdftex.def
File: pdftex.def 2018/01/08 v1.0l Graphics/color driver for pdftex
)
Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1348.
Package xcolor Info: Model `hsb' substituted by `rgb' on input line 1352.
Package xcolor Info: Model `RGB' extended on input line 1364.
Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1366.
Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1367.
Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1368.
Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1369.
Package xcolor Info: Model `Gray' substituted by `gray' on input line 1370.
Package xcolor Info: Model `wave' substituted by `hsb' on input line 1371.
)
runsystem(which pygmentize && touch PraxisphaseAufsatz.aex)...executed.



! Package minted Error: You must have `pygmentize' installed to use this packag
e.

See the minted package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.5 \begin{document}

Refer to the installation instructions in the minted documentation for more inf
ormation.

(./PraxisphaseAufsatz.aux)
\openout1 = `PraxisphaseAufsatz.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 5.
LaTeX Font Info:    ... okay on input line 5.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 5.
LaTeX Font Info:    ... okay on input line 5.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 5.
LaTeX Font Info:    ... okay on input line 5.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 5.
LaTeX Font Info:    ... okay on input line 5.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 5.
LaTeX Font Info:    ... okay on input line 5.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 5.
LaTeX Font Info:    ... okay on input line 5.

(/usr/local/texlive/2019/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
\scratchcounter=\count119
\scratchdimen=\dimen120
\scratchbox=\box36
\nofMPsegments=\count120
\nofMParguments=\count121
\everyMPshowfont=\toks19
\MPscratchCnt=\count122
\MPscratchDim=\dimen121
\MPnumerator=\count123
\makeMPintoPDFobject=\count124
\everyMPtoPDFconversion=\toks20
)
\openout3 = `PraxisphaseAufsatz.pyg'.

runsystem(pygmentize -S default -f latex -P commandprefix=PYG > _minted-Praxisp
haseAufsatz/default-pyg-prefix.pygstyle)...executed.



! Package minted Error: Missing Pygments output; \inputminted was
probably given a file that does not exist--otherwise, you may need 
the outputdir package option, or may be using an incompatible build tool,
or may be using frozencache with a missing file.

See the minted package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.11    \end{minted}^^M

This could be caused by using -output-directory or -aux-directory 
without setting minted's outputdir, or by using a build tool that 
changes paths in ways minted cannot detect, 
or using frozencache with a missing file.

runsystem(pygmentize -S default -f latex -P commandprefix=PYGdefault > _minted-
PraxisphaseAufsatz/default.pygstyle)...executed.


! Package minted Error: Missing Pygments output; \inputminted was
probably given a file that does not exist--otherwise, you may need 
the outputdir package option, or may be using an incompatible build tool,
or may be using frozencache with a missing file.

See the minted package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.11    \end{minted}^^M

This could be caused by using -output-directory or -aux-directory 
without setting minted's outputdir, or by using a build tool that 
changes paths in ways minted cannot detect, 
or using frozencache with a missing file.

runsystem(pygmentize -l c -f latex -P commandprefix=PYG -F tokenmerge -o _minte
d-PraxisphaseAufsatz/916909323916480C99F1AA97E621BB15219288A92FD0AFDEBD8CE6CF1E
55BAC6.pygtex PraxisphaseAufsatz.pyg)...executed.


! Package minted Error: Missing Pygments output; \inputminted was
probably given a file that does not exist--otherwise, you may need 
the outputdir package option, or may be using an incompatible build tool,
or may be using frozencache with a missing file.

See the minted package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.11    \end{minted}

This could be caused by using -output-directory or -aux-directory 
without setting minted's outputdir, or by using a build tool that 
changes paths in ways minted cannot detect, 
or using frozencache with a missing file.

(./PraxisphaseAufsatz.aux)
runsystem(rm PraxisphaseAufsatz.pyg)...executed.

runsystem(rm PraxisphaseAufsatz.out.pyg)...executed.

 ) 
Here is how much of TeX's memory you used:
 4533 strings out of 492167
 82218 string characters out of 6125388
 193966 words of memory out of 5000000
 8870 multiletter control sequences out of 15000+600000
 3640 words of font info for 14 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 42i,1n,37p,833b,142s stack positions out of 5000i,500n,10000p,200000b,80000s

No pages of output.
PDF statistics:
 0 PDF objects out of 1000 (max. 8388607)
 0 named destinations out of 1000 (max. 500000)
 1 words of extra memory for PDF output out of 10000 (max. 10000000)

标签: latexpygments

解决方案


如果 anaconda python 二进制文件尚未在所有应用程序的搜索路径中,则可以通过以下方式将其添加到 texstudio 搜索路径中Preferences->Build->Commands ($PATH)

在此处输入图像描述

如果这个python版本应该适用于所有应用程序,也可以全局添加到路径中,参见https://apple.stackexchange.com/questions/51677/how-to-set-path-for-finder-launched-应用程序(这可能会导致发布自己的 python 版本的应用程序出现问题)


推荐阅读