[Tex/LaTex] Minted error: Missing pygments error

minted

I have installed the minted package and inserted the –shell-escape command in the settings of TexWorks.

\documentclass{article}
\usepackage{minted}


\begin{document}
\begin{minted}{python}
import nump as np
\end{minted}
\end{document}

This s the console output.

This is pdfTeX, Version 3.14159265-2.6-1.40.17 (MiKTeX 2.9.6210 64-bit)
entering extended mode
(untitled-2.tex
LaTeX2e <2017/01/01> patch level 1
Babel <3.9r> and hyphenation patterns for 75 language(s) loaded.
("C:\Program Files\MiKTeX 2.9\tex\latex\base\article.cls"
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
("C:\Program Files\MiKTeX 2.9\tex\latex\base\size10.clo"))
("C:\Program Files\MiKTeX 2.9\tex\latex\minted\minted.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\keyval.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\kvoptions.sty"
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ltxcmds.sty")
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\kvsetkeys.sty"
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\infwarerr.sty")
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\etexcmds.sty"
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifluatex.sty"))))
("C:\Program Files\MiKTeX 2.9\tex\latex\fvextra\fvextra.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\base\ifthen.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\etoolbox\etoolbox.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\fancyvrb\fancyvrb.sty"
Style option: `fancyvrb' v3.2a <2019/01/15> (tvz))
("C:\Program Files\MiKTeX 2.9\tex\latex\upquote\upquote.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\lineno\lineno.sty"))
("C:\Program Files\MiKTeX 2.9\tex\latex\tools\calc.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\tools\shellesc.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\ifplatform\ifplatform.sty"
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\pdftexcmds.sty"
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifpdf.sty"))
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\catchfile.sty"))
("C:\Program Files\MiKTeX 2.9\tex\latex\xstring\xstring.sty"
("C:\Program Files\MiKTeX 2.9\tex\generic\xstring\xstring.tex"))
("C:\Program Files\MiKTeX 2.9\tex\latex\framed\framed.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\float\float.sty"))
("C:\Program Files\MiKTeX 2.9\tex\latex\xcolor\xcolor.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics-cfg\color.cfg")
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics-def\pdftex.def"))
E:\data>set  /p x=E:\Anaconda3\pkgs\pygments-2.3.1-py37_0\Scripts\pygmentize.exe 0<nul: 1>>untitled-2.aex 

E:\data>set  /p x= 0<nul: 1>>untitled-2.aex 

E:\data>set  /p x= 0<nul: 1>>untitled-2.aex 

No file untitled-2.aux.
("C:\Program Files\MiKTeX 2.9\tex\context\base\supp-pdf.mkii"
[Loading MPS to PDF converter (version 2006.09.02).]
)Unable to create process using 'E:\Anaconda3\pkgs\pygments-2.3.1-py37_0\python.exe E:\Anaconda3\pkgs\pygments-2.3.1-py37_0\Scripts\pygmentize-script.py -S default -f latex -P commandprefix=PYG '
 (_minted-untitled-2/default-pyg-prefix.pygstyle)Unable to create process using 'E:\Anaconda3\pkgs\pygments-2.3.1-py37_0\python.exe E:\Anaconda3\pkgs\pygments-2.3.1-py37_0\Scripts\pygmentize-script.py -S default -f latex -P commandprefix=PYGdefault '

(_minted-untitled-2/default.pygstyle)Unable to create process using 'E:\Anaconda3\pkgs\pygments-2.3.1-py37_0\python.exe E:\Anaconda3\pkgs\pygments-2.3.1-py37_0\Scripts\pygmentize-script.py -l python -f latex -P commandprefix=PYG -F tokenmerge -o _minted-untitled-2/A9E2CF9A87AD555C76527CE1FE6BA6800BAB9765B70F998031078A806C12B4A4.pygtex untitled-2.pyg'


! 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.8 \end{minted}

? 

I have also added pygmentize.exe to the Path environment variables. I think there is some problem with the pygmentize.exe.

Best Answer

Solution: For minted to work, pygmentize.exe needs to be added to the Path environment. If using the conda distribution, there could be two versions of the pygmentize.exe.

1) C:\Anaconda3\pkgs\pygments-2.3.1-py37_0\Scripts

2) C:\Anaconda3\Scripts

I added the first directory to my Path environment variables, which resulted in the error mentioned. Removing the first and adding the second, fixed the problem and minted works just fine.

PC needs to be restarted everytime you change environmental variables.