尽管已安装,但 TexStudio 找不到包“Pygments”

尽管已安装,但 TexStudio 找不到包“Pygments”

我尝试使用mintedlatex 中的包在 latex 文档中显示代码。从 Texstudio,我收到一条错误消息you must have pygmentize installed to use this package

如果我输入,pip3 install pygments我会得到 Requirement already satisfied: pygments in /usr/local/lib/python3.7/site-packages (2.3.1)意味着pip3已安装在机器上。

因此,输入后,pip3 show Pygments我得到了安装该包的路径,即:/usr/local/lib/python3.7/site-packages。此外,当我从启动pythonTerminal并输入时import pygments,没有显示任何错误消息。这意味着它已正确安装,但latex编辑器找不到它。

我究竟做错了什么?

编辑 正如以下答案所指出的那样

我收到第一条消息:

Package minted Error: You must invoke LaTeX with the -shell-escape flag. \begin

只有这样我才能得到:

Package minted Error: You must have `pygmentize' installed to use this package. \begin{document}
Package minted Error: Missing Pygments output; \inputminted wasor may be using frozencache with a missing file. \end{minted}^^M
Package minted Error: Missing Pygments output; \inputminted wasor may be using frozencache with a missing file. \end{minted}^^M
Package minted Error: Missing Pygments output; \inputminted wasor may be using frozencache with a missing file. \end{minted}
shell escape is disabled, so I can only detect \ifwindows.

以下是一段代码:

\documentclass[a4paper, 12pt]{book}
\usepackage{minted}
\begin{document}
\chapter{Introduction}
\begin{minted}{python}
print("hello world")
\end{minted}
\end{document}

编辑2

正如另一个答案所指出的那样,问题似乎出在配置选项中。因此,进入“Textstudio > 首选项 > 构建”后,我单击按钮Addpdflatex -shell-escape在左侧单元格和pdflatex -synctex=1 -interaction=nonstopmode --shell-escape %.tex右侧单元格中输入,如下所示:

添加命令

我在用户菜单中确实得到了一个新命令:

在此处输入图片描述

然后我退出该菜单,但问题仍然存在。

我还缺少什么

以下是日志文件的列表:

日志档案

这是打印的日志文件:

This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) (preloaded format=pdflatex 2018.9.16)  23 APR 2019 20:44
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**python_latex.tex
(./python_latex.tex
LaTeX2e <2018-04-01> patch level 2
Babel <3.18> and hyphenation patterns for 84 language(s) loaded.
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/book.cls
Document Class: book 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/bk12.clo
File: bk12.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
)
\c@part=\count80
\c@chapter=\count81
\c@section=\count82
\c@subsection=\count83
\c@subsubsection=\count84
\c@paragraph=\count85
\c@subparagraph=\count86
\c@figure=\count87
\c@table=\count88
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
(/usr/local/texlive/2018/texmf-dist/tex/latex/minted/minted.sty
Package: minted 2017/07/19 v2.5 Yet another Pygments shim for LaTeX

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

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

(/usr/local/texlive/2018/texmf-dist/tex/generic/oberdiek/infwarerr.sty
Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO)
)
(/usr/local/texlive/2018/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/2018/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.
)
Package etexcmds Info: Could not find \expanded.
(etexcmds)             That can mean that you are not using pdfTeX 1.50 or
(etexcmds)             that some package has redefined \expanded.
(etexcmds)             In the latter case, load this package earlier.
)))
(/usr/local/texlive/2018/texmf-dist/tex/latex/fvextra/fvextra.sty
Package: fvextra 2017/07/08 v1.3.1 fvextra - extensions and patches for fancyvr
b

(/usr/local/texlive/2018/texmf-dist/tex/latex/base/ifthen.sty
Package: ifthen 2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
)
(/usr/local/texlive/2018/texmf-dist/tex/latex/etoolbox/etoolbox.sty
Package: etoolbox 2018/02/11 v2.5e e-TeX tools for LaTeX (JAW)
\etb@tempcnta=\count89
)
(/usr/local/texlive/2018/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty
Package: fancyvrb 2008/02/07

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

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

(/usr/local/texlive/2018/texmf-dist/tex/generic/oberdiek/ifpdf.sty
Package: ifpdf 2017/03/15 v3.2 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/2018/texmf-dist/tex/generic/oberdiek/catchfile.sty
Package: catchfile 2016/05/16 v1.7 Catch the contents of a file (HO)
)

Package ifplatform Warning: 
    shell escape is disabled, so I can only detect \ifwindows.

) (/usr/local/texlive/2018/texmf-dist/tex/generic/xstring/xstring.sty
(/usr/local/texlive/2018/texmf-dist/tex/generic/xstring/xstring.tex
\@xs@message=\write4
\integerpart=\count114
\decimalpart=\count115
)
Package: xstring 2013/10/13  v1.7c  String manipulations (C Tellechea)
)
(/usr/local/texlive/2018/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=\dimen115
\fb@frh=\dimen116
\FrameRule=\dimen117
\FrameSep=\dimen118
)
(/usr/local/texlive/2018/texmf-dist/tex/latex/float/float.sty
Package: float 2001/11/08 v1.3d Float enhancements (AL)
\c@float@type=\count116
\float@exts=\toks16
\float@box=\box32
\@float@everytoks=\toks17
\@floatcapt=\box33
)
\minted@appexistsfile=\read2
\minted@bgbox=\box34
\minted@code=\write5
\c@minted@FancyVerbLineTemp=\count117
\c@minted@pygmentizecounter=\count118
\@float@every@listing=\toks18
\c@listing=\count119
)
runsystem(mkdir -p _minted-python_latex)...disabled (restricted).



! Package minted Error: You must invoke LaTeX with the -shell-escape flag.

See the minted package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.3 \begin
          {document}
Pass the -shell-escape flag to LaTeX. Refer to the minted.sty documentation for
 more information.

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

(/usr/local/texlive/2018/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/2018/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 python_latex.aex)...disabled (restricted).



! 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.3 \begin{document}
                    
Refer to the installation instructions in the minted documentation for more inf
ormation.

(./python_latex.aux)
\openout1 = `python_latex.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.

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

runsystem(pygmentize -S default -f latex -P commandprefix=PYG > _minted-python_
latex/default-pyg-prefix.pygstyle)...disabled (restricted).


! 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.7 \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-
python_latex/default.pygstyle)...disabled (restricted).


! 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.7 \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 python -f latex -P commandprefix=PYG -F tokenmerge -o _
minted-python_latex/72214DB4E1E543018D1BAFE86EA3B4440B40C301701A64D52CDA79C72DA
628CC.pygtex python_latex.pyg)...disabled (restricted).


! 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.7 \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.

[1


{/usr/local/texlive/2018/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./python_latex.aux)
runsystem(rm python_latex.pyg)...disabled (restricted).

 ) 
Here is how much of TeX's memory you used:
 4355 strings out of 492649
 78111 string characters out of 6129622
 188991 words of memory out of 5000000
 8209 multiletter control sequences out of 15000+600000
 4544 words of font info for 17 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 37i,5n,35p,843b,142s stack positions out of 5000i,500n,10000p,200000b,80000s
</usr/local/texlive/2018/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx12.pfb
></usr/local/texlive/2018/texmf-dist/fonts/type1/public/amsfonts/cm/cmr12.pfb>
Output written on python_latex.pdf (1 page, 17712 bytes).
PDF statistics:
 16 PDF objects out of 1000 (max. 8388607)
 10 compressed objects within 1 object stream
 0 named destinations out of 1000 (max. 500000)
 1 words of extra memory for PDF output out of 10000 (max. 10000000)

回答 正如链接问题的帖子所指出的,只需在文档中插入以下行:% !TeX TXS-program:compile = txs:///pdflatex/[--shell-escape]

答案1

! Package minted Error: You must have 'pygmentize' installed to use this package.

第一的您收到错误消息,或者在此之前您收到

! Package minted Error: You must invoke LaTeX with the -shell-escape flag.

检查 latex 运行的日志文件,其中还应该不是说在第 3 行

restricted \write18 enabled.

应该说

\write18 enabled.

如果日志说限制写入 18,那么使用-shell-escapepdflatex 选项。

相关内容