使用 minted 包进行编译时出现 Pygmentize 错误

使用 minted 包进行编译时出现 Pygmentize 错误

pygment 包已放置在 python 文件夹以及 python 文件夹内的 scripts 子文件夹中;也已添加到 PATH;但仍然出现以下错误

请求指导如何克服此错误

在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

\documentclass{article}
\usepackage{minted}

\begin{document}

\begin{minted}[mathescape, linenos]{python}

# Note: $\pi=\lim_{n\to\infty}\frac{P_n}{d}$
title = "Hello World"

sum = 0
for i in range(10):
 sum += i

\end{minted}

\end{document}

编辑

在 ST3 的用户偏好设置中添加了 shell-escape 选项

在此处输入图片描述

通过添加 pippython -m ensurepip --default-pip

pip --version 仍然显示错误

在此处输入图片描述

pip 现已安装

在此处输入图片描述

ST3 构建引擎设置如下// ----------------------------------------

--------------------------
// Build engine settings
// ------------------------------------------------------------------

    // OPTION: "builder"
    // Specifies a build engine
    // Possible values:
    //
    // "default" or ""  the default built-in build engine; currently
    //                  this is the same as "traditional"
    //
    // "basic"          invokes pdflatex / xelatex / lualatex as
    //                  needed, then biber / bibtex and pdflatex /
    //                  xelatex / lualatex again if needed. Unlike
    //                  the "simple" builder this supports most of
    //                  LaTeXTools builder features.
    //
    // "script"         external script: invokes the set of commands
    //                  specified in the "script_commands" setting
    //                  in the platform-specific part of the
    //                  "builder_settings"
    //
    // "simple"         invokes pdflatex 1x or 2x as needed, then
    //                  bibtex and pdflatex again if needed;
    //                  intended mainly as a simple example for
    //                  people writing their own build engines.
    //
    // "traditional"    replicates the 'old' system based on
    //                  latexmk (TeXLive) / texify (MiKTeX)
    //
    // custom name      you can also use third-party build engines;
    //                  if so, set the "builder_path" option below
    //
    // NOTE: custom builders CANNOT have the same name as an existing
    // built-in build engine (including "default")

    "builder": "traditional",

    // OPTION: "builder_path"
    // If non-empty, specifies a path to a custom builder, relative to the
    // Sublime Text Packages directory.
    // For instance, "User/builders" (on Windows: "User\builders") is a good
    // choice if you roll your own.
    // (Note: if you choose "User", you may get a Python import error in the
    // console, but things will still work).
    // Leave empty ("") for a built-in builder.

    "builder_path": "",

    // OPTION: "builder_settings"
    // Specify builder-dependent settings and preferences
    // Possible values: see README or documentation provided with
    // third-party build engine.
    // Builder setting can be general or OS-dependent

    "builder_settings" : {

        // General settings:
        // See README or third-party documentation

        // (built-ins): true shows the log of each command in the output panel
        "display_log" : false,
        "options": ["--shell-escape"],

        // Platform-specific settings:
        "osx" : {
            // See README or third-party documentation
        },

        "windows" : {
            // See README or third-party documentation
        },

        "linux" : {
            // See README or third-party documentation
        }
    },

以及日志文件

This is pdfTeX, Version 3.14159265-2.6-1.40.20 (MiKTeX 2.9.7140 64-bit) (preloaded format=pdflatex 2019.9.14)  19 DEC 2019 20:50
entering extended mode
**./minted1.tex
(minted1.tex
LaTeX2e <2018-12-01>

("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/latex/base\article.c
ls"
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class

("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/latex/base\size10.cl
o"
File: size10.clo 2018/09/03 v1.4i 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
)
("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/latex/minted\minted.
sty"
Package: minted 2017/07/19 v2.5 Yet another Pygments shim for LaTeX

("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/latex/graphics\keyva
l.sty"
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks14
)
("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/latex/oberdiek\kvopt
ions.sty"
Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO)

("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/generic/oberdiek\ltx
cmds.sty"
Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
)
("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/generic/oberdiek\kvs
etkeys.sty"
Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO)

("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/generic/oberdiek\inf
warerr.sty"
Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO)
)
("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/generic/oberdiek\ete
xcmds.sty"
Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)

("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/generic/oberdiek\ifl
uatex.sty"
Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO)
Package ifluatex Info: LuaTeX not detected.
))))
("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/latex/fvextra\fvextr
a.sty"
Package: fvextra 2019/02/04 v1.4 fvextra - extensions and patches for fancyvrb

("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/latex/base\ifthen.st
y"
Package: ifthen 2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
)
("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/latex/etoolbox\etool
box.sty"
Package: etoolbox 2018/08/19 v2.5f e-TeX tools for LaTeX (JAW)
\etb@tempcnta=\count88
)
("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/latex/fancyvrb\fancy
vrb.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
)
("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/latex/upquote\upquot
e.sty"
Package: upquote 2012/04/19 v1.3 upright-quote and grave-accent glyphs in verba
tim
)
("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\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
)
("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\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
)
("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/latex/tools\shellesc
.sty"
Package: shellesc 2016/06/07 v0.02a unified shell escape interface for LaTeX
Package shellesc Info: Unrestricted shell escape enabled on input line 67.
)
("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/latex/ifplatform\ifp
latform.sty"
Package: ifplatform 2017/10/13 v0.4a Testing for the operating system

("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/generic/oberdiek\pdf
texcmds.sty"
Package: pdftexcmds 2019/07/25 v0.30 Utility functions of pdfTeX for LuaTeX (HO
)

("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/generic/oberdiek\ifp
df.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.
)
("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/generic/oberdiek\cat
chfile.sty"
Package: catchfile 2016/05/16 v1.7 Catch the contents of a file (HO)
))
("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/latex/xstring\xstrin
g.sty"
("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/generic/xstring\xstr
ing.tex"
\integerpart=\count113
\decimalpart=\count114
)
Package: xstring 2019/02/06 v1.83 String manipulations (CT)
)
("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\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
)
("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/latex/float\float.st
y"
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(if not exist _minted-minted1 mkdir _minted-minted1)...executed.


("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/latex/xcolor\xcolor.
sty"
Package: xcolor 2016/05/11 v2.12 LaTeX color extensions (UK)

("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/latex/graphics-cfg\c
olor.cfg"
File: color.cfg 2016/01/02 v1.6 sample color configuration
)
Package xcolor Info: Driver file: pdftex.def on input line 225.

("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/latex/graphics-def\p
dftex.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(for ^%i in (pygmentize.exe pygmentize.bat pygmentize.cmd) do set > mi
nted1.aex <nul: /p x=^%~$PATH:i>> minted1.aex)...executed.

runsystem(del minted1.aex)...executed.

 (minted1.aux)
\openout1 = `minted1.aux'.

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

("C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\tex/context/base/mkii\su
pp-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 = `minted1.pyg'.

 (_minted-minted1/default-pyg-prefix.pygstyle)
(_minted-minted1/default.pygstyle)
runsystem(pygmentize -l c -f latex -P commandprefix=PYG -F tokenmerge -o _minte
d-minted1/FE9278EB93A86E9D4FBEC15E67F94CB1095E436DF31F1005096016EE0C5AC944.pygt
ex minted1.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.9 \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.

(minted1.aux)
runsystem(del minted1.pyg)...executed.

 ) 
Here is how much of TeX's memory you used:
 4490 strings out of 492895
 83203 string characters out of 3121865
 192124 words of memory out of 3000000
 8376 multiletter control sequences out of 15000+200000
 3640 words of font info for 14 fonts, out of 3000000 for 9000
 1141 hyphenation exceptions out of 8191
 37i,1n,35p,840b,142s stack positions out of 5000i,500n,10000p,200000b,50000s

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)

编辑2

按照以下详细信息操作后https://alipourmousavi.com/blog/index.php/2018/02/08/using-minted-package-in-latex-to-format-codes/

PATH已设置并显示如下\Pygments 已安装\wheel 也已完成\setuptools 已完成\

NUMBER_OF_PROCESSORS=8
OS=Windows_NT
Path=C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Calibre2\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Pandoc\;C:\Users\J S Bibra\AppData\Local\Microsoft\WindowsApps;C:\Users\J S Bibra\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64\;C:\Users\J S Bibra\AppData\Local\GitHubDesktop\bin;C:\Python38;C:\Python38\Scripts;C:\Python38\Scripts\Pygments-2.5.2;C:\Users\J S Bibra\AppData\Local\Programs\Python\Python38\Scripts;C:\Users\J S Bibra\AppData\Local\Programs\Python\Python38;C:\Users\J S Bibra\AppData\Local\Programs\Python
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=5e03
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows

跟随误差

 Package minted Error: Missing Pygments output; \inputminted was [\end{minted}]

使用的代码

\documentclass[10pt,a4paper]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}

\usepackage{minted}

\begin{document}
\begin{minted}{python}
import numpy as np

def incmatrix(genl1,genl2):
    m = len(genl1)
    n = len(genl2)
    M = None #to become the incidence matrix
    VT = np.zeros((n*m,1), int)  #dummy variable

    #compute the bitwise xor matrix
    M1 = bitxormatrix(genl1)
    M2 = np.triu(bitxormatrix(genl2),1) 

    for i in range(m-1):
        for j in range(i+1, m):
            [r,c] = np.where(M2 == M1[i,j])
            for k in range(len(r)):
                VT[(i)*n + r[k]] = 1;
                VT[(i)*n + c[k]] = 1;
                VT[(j)*n + r[k]] = 1;
                VT[(j)*n + c[k]] = 1;

                if M is None:
                    M = np.copy(VT)
                else:
                    M = np.concatenate((M, VT), 1)

                VT = np.zeros((n*m,1), int)

    return M
\end{minted}
\end{document}

请问有什么建议吗?

我也看到了不受限制的 shell 逃逸

在此处输入图片描述

lo文件中的错误信息

在此处输入图片描述

答案1

Pygmentize还需要Python,请安装最新版本并安装Pygmentize然后运行您的文件,您的代码对我来说工作正常......

请注意,您必须通过-shell-escape选项运行 LaTeX 或 PDFLaTeX...

输出

在此处输入图片描述

答案2

最后

在……的帮助下开始工作

https://github.com/SublimeText/LaTeXTools/issues/657#issuecomment-414410430

解决方案是输入路径--

"texpath" : "C:/Users/J S Bibra/AppData/Local/Programs/Python/Python38/Scripts",

在 ST3 > 首选项 > 包设置 > LatexTools > 设置 - 用户 > 平台设置

在此处输入图片描述

运行代码

\documentclass{article}
\usepackage[cache=false]{minted}

\begin{document}

\begin{minted}[mathescape, linenos]{python}

# Note: $\pi=\lim_{n\to\infty}\frac{P_n}{d}$
title = "Hello World"

sum = 0
for i in range(10):
 sum += i

\end{minted}

\end{document}

给了魔术界期待已久的输出

在此处输入图片描述

非常感谢@guilgautierhttps://github.com/SublimeText/LaTeXTools/issues/657#issuecomment-414410430

完了,走吧

已关闭的问题

相关内容