gpoore / minted

minted is a LaTeX package that provides syntax highlighting using the Pygments library. Highlighted source code can be customized using fancyvrb.
1.75k stars 127 forks source link

[Win 10 - Texlive] Failed to find installed `pygmentize' #280

Closed PeterQiu0516 closed 3 years ago

PeterQiu0516 commented 4 years ago

I edit the minted.tex testing file as: image

When i run pdflatex -shell-escape minted.tex in the same directory as instructed in the terminal, it promted my with

image

Then I press enter it will print out the following error message

image

I have read through the mint.sty and this error probably comes from failing to locate pygmentize.exe image

But I could run in the same directory: image

Also, I found the pygmentize.exe file in image

Which I already added to the PATH: image

I can also compile any other LaTeX file which does not include minted.

My LaTeX version: image

Could anyone offer any help?

muzimuzhi commented 4 years ago

Try to install Pygments as a python 3 package. Currently you install it as a python 2.7 package.

You can run pygmentize -h to check whether it is correctly installed.

PeterQiu0516 commented 4 years ago

Try to install Pygments as a python 3 package. Currently you install it as a python 2.7 package.

You can run pygmentize -h to check whether it is correctly installed.

Sorry but my python version is 3.7.2? And I tried pip3 install Pygments it still prompts me that my package is up-to-date? image

muzimuzhi commented 4 years ago

What do you get from pygmentize -h?

PeterQiu0516 commented 4 years ago

What do you get from pygmentize -h?

image

image

muzimuzhi commented 4 years ago

Looks OK.

Suppose you have file C:\Users\qiuch\Desktop\MATH-371\Homeworks\hw1\tex\main.c containing

int main() {
  printf("hello, world");
}

What do you get from running pygmentize -l c -f latex -P commandprefix=PYG -F tokenmerge main.c? The expected stdout is

\begin{Verbatim}[commandchars=\\\{\}]
\PYG{k+kt}{int} \PYG{n+nf}{main}\PYG{p}{()} \PYG{p}{\PYGZob{}}
  \PYG{n}{printf}\PYG{p}{(}\PYG{l+s}{\PYGZdq{}hello, world\PYGZdq{}}\PYG{p}{);}
\PYG{p}{\PYGZcb{}}
\end{Verbatim}

PS: You can copy-and-paste the text of stdout, instead of screenshoots.

PeterQiu0516 commented 4 years ago

It just gives the correct output:

C:\Users\qiuch\Desktop\MATH-371\Homework\hw1\tex>pygmentize -l c -f latex -P commandprefix=PYG -F tokenmerge main.c
\begin{Verbatim}[commandchars=\\\{\}]
\PYG{k+kt}{int} \PYG{n+nf}{main}\PYG{p}{()} \PYG{p}{\PYGZob{}}
  \PYG{n}{printf}\PYG{p}{(}\PYG{l+s}{\PYGZdq{}hello, world\PYGZdq{}}\PYG{p}{);}
\PYG{p}{\PYGZcb{}}
\end{Verbatim}
muzimuzhi commented 4 years ago

Delete every aux file of minted.tex, including the aux subfolder _minted-minted, then try again? I've tested your example (see below) on Overleaf.com with its texlive 2018, and it complies without any errors.

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

\begin{document}
\begin{minted}{c}
int main() {
printf("hello, world");
}
\end{minted}
\end{document}
PeterQiu0516 commented 4 years ago

Sorry but the error remains unsolved:

C:\Users\qiuch\Desktop\MATH-371\Homework\hw1\tex>ls -a
.   .log                     2020-09-13-15-38-23.png  homework_1.aux  homework_1.pdf         homework_1.tex  minted.tex
..  2020-09-12-17-21-31.png  2020-09-13-15-51-23.png  homework_1.log  homework_1.synctex.gz  main.c          texput.log

C:\Users\qiuch\Desktop\MATH-371\Homework\hw1\tex>ls minted.*
minted.tex

C:\Users\qiuch\Desktop\MATH-371\Homework\hw1\tex>pdflatex -shell-escape minted
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018/W32TeX) (preloaded format=pdflatex)
 \write18 enabled.
entering extended mode
(./minted.tex
LaTeX2e <2018-04-01> patch level 2
Babel <3.18> and hyphenation patterns for 84 language(s) loaded.
(c:/texlive/2018/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(c:/texlive/2018/texmf-dist/tex/latex/base/size10.clo))
(c:/texlive/2018/texmf-dist/tex/latex/minted/minted.sty
(c:/texlive/2018/texmf-dist/tex/latex/graphics/keyval.sty)
(c:/texlive/2018/texmf-dist/tex/latex/oberdiek/kvoptions.sty
(c:/texlive/2018/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)
(c:/texlive/2018/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
(c:/texlive/2018/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(c:/texlive/2018/texmf-dist/tex/generic/oberdiek/etexcmds.sty
(c:/texlive/2018/texmf-dist/tex/generic/oberdiek/ifluatex.sty))))
(c:/texlive/2018/texmf-dist/tex/latex/fvextra/fvextra.sty
(c:/texlive/2018/texmf-dist/tex/latex/base/ifthen.sty)
(c:/texlive/2018/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(c:/texlive/2018/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty
Style option: `fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix
<2008/02/07> (tvz)) (c:/texlive/2018/texmf-dist/tex/latex/upquote/upquote.sty)
(c:/texlive/2018/texmf-dist/tex/latex/lineno/lineno.sty))
(c:/texlive/2018/texmf-dist/tex/latex/tools/calc.sty)
(c:/texlive/2018/texmf-dist/tex/latex/tools/shellesc.sty)
(c:/texlive/2018/texmf-dist/tex/latex/ifplatform/ifplatform.sty
(c:/texlive/2018/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
(c:/texlive/2018/texmf-dist/tex/generic/oberdiek/ifpdf.sty))
(c:/texlive/2018/texmf-dist/tex/generic/oberdiek/catchfile.sty))
(c:/texlive/2018/texmf-dist/tex/generic/xstring/xstring.sty
(c:/texlive/2018/texmf-dist/tex/generic/xstring/xstring.tex))
(c:/texlive/2018/texmf-dist/tex/latex/framed/framed.sty)
(c:/texlive/2018/texmf-dist/tex/latex/float/float.sty))
(c:/texlive/2018/texmf-dist/tex/latex/xcolor/xcolor.sty
(c:/texlive/2018/texmf-dist/tex/latex/graphics-cfg/color.cfg)
(c:/texlive/2018/texmf-dist/tex/latex/graphics-def/pdftex.def))system returned with code -1

\minted@apppathifexists=

! 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}

? ^Z

! Emergency stop.
 ...

l.3 \begin{document}

!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on minted.log.

Maybe I should try reinstall the Tex Live and Python on my computer.

PeterQiu0516 commented 4 years ago

The error log file: minted.log

muzimuzhi commented 4 years ago

Your minted.log shows

(c:/texlive/2018/texmf-dist/tex/latex/minted/minted.sty
Package: minted 2017/09/03 v2.5.1dev Yet another Pygments shim for LaTeX

but the latest public release of minted is v2.5. Did you manually install the minted.sty? If so, then try the v2.5 version.


Update: Sorry, that might not be the source of problem. My local tests for 2017/09/03 v2.5.1dev works as well.

muzimuzhi commented 4 years ago

Could you compile the following example (with -shell-escape), and upload the resulting log file? Also, which version of Windows do you use?

Update: Ah, you've already mentioned win10.

\documentclass{article}
\usepackage[draft]{minted}

\begin{document}
\begingroup
\tracingall
\TestAppExists{\MintedPygmentize}
\ifAppExists
  True
\else
  False
\fi
\endgroup
\end{document}
PeterQiu0516 commented 4 years ago

Your minted.log shows

(c:/texlive/2018/texmf-dist/tex/latex/minted/minted.sty
Package: minted 2017/09/03 v2.5.1dev Yet another Pygments shim for LaTeX

but the latest public release of minted is v2.5. Did you manually install the minted.sty? If so, then try the v2.5 version.

Update: Sorry, that might not be the source of problem. My local tests for 2017/09/03 v2.5.1dev works as well.

Yes, I have tried using v2.5 and it does not help.

PeterQiu0516 commented 4 years ago

Could you compile the following example (with -shell-escape), and upload the resulting log file? Also, which version of Windows do you use?

Update: Ah, you've already mentioned win10.

\documentclass{article}
\usepackage[draft]{minted}

\begin{document}
\begingroup
\tracingall
\TestAppExists{\MintedPygmentize}
\ifAppExists
  True
\else
  False
\fi
\endgroup
\end{document}

Logfile: draft.log

It seems to compile?

muzimuzhi commented 4 years ago

Yes it always compiles. Expected output is "True", while you get "False".

It seems the following windows CMD command thinks pygmentize.exe is not in your path, hence temp file draft.aex is not created created but empty, which then results in \ifAppExists being set false.

for ^%i in (pygmentize.exe pygmentize.bat pygmentize.cmd) do set > draft.aex <nul: /p x=^%~$PATH:i>> draft.aex

I'm on macOS and not familiar with Windows. Perhaps there are problems in your PATH setting. This answer on superuser.com suggested one should

Make sure TeX prioritizes the correct PATH.

by

click "Move up" until it (the path of pygmentize.exe) is above any TeX related paths.

Restart your computer. Minted should now work :)

PeterQiu0516 commented 4 years ago

Yes it always compiles. Expected output is "True", while you get "False".

It seems the following windows CMD command thinks pygmentize.exe is not in your path, hence temp file draft.aex is not created, which then results in \ifAppExists being set false.

for ^%i in (pygmentize.exe pygmentize.bat pygmentize.cmd) do set > draft.aex <nul: /p x=^%~$PATH:i>> draft.aex

I'm on macOS and not familiar with Windows. Perhaps there are problems in your PATH setting. This answer on superuser.com suggested one should

Make sure TeX prioritizes the correct PATH.

by

click "Move up" until it (the path of pygmentize.exe) is above any TeX related paths. Restart your computer. Minted should now work :)

Actually I have read and tried this method before and it did not work (I have tried both priorities that TeX > Python\Scripts and Python\Scripts > Tex). I have also tried to put the pygmentize.exe in the working directory & CMD directory & Scripts directory , the same error still occur.

Anyway, thanks for your help :)

yanxwb commented 3 years ago

Is it solved now? I met similar problems, and I've tried solutions above. But it seems doesn't work.

PeterQiu0516 commented 3 years ago

Is it solved now? I met similar problems, and I've tried solutions above. But it seems doesn't work.

Is is still unsolved TAT. And I use other package instead.

yanxwb commented 3 years ago

Is it solved now? I met similar problems, and I've tried solutions above. But it seems doesn't work.

Is is still unsolved TAT. And I use other package instead.

Do you have any other recommendations? I found lstlisting not so pretty. ┭┮﹏┭┮

PeterQiu0516 commented 3 years ago

Is it solved now? I met similar problems, and I've tried solutions above. But it seems doesn't work.

Is is still unsolved TAT. And I use other package instead.

Do you have any other recommendations? I found lstlisting not so pretty. ┭┮﹏┭┮

Actually I still used lstlisting now, I tried to beautify it by customizing fonts, highlights and so on.

yanxwb commented 3 years ago

Is it solved now? I met similar problems, and I've tried solutions above. But it seems doesn't work.

Is is still unsolved TAT. And I use other package instead.

Do you have any other recommendations? I found lstlisting not so pretty. ┭┮﹏┭┮

Actually I still used lstlisting now, I tried to beautify it by customizing fonts, highlights and so on.

Okay, maybe I'll have a try. Thanks :)

tugkan0153 commented 3 years ago

I have the same problem on Windows 7, MikTex-21.2, minted-2.5 and pygmentize-2.9.0, i.e. the latest version of minted and pygmentize.

@muzimuzhi I've tried the code

\documentclass{article}
\usepackage[draft]{minted}

\begin{document}
\begingroup
\tracingall
\TestAppExists{\MintedPygmentize}
\ifAppExists
  True
\else
  False
\fi
\endgroup
\end{document}

and compiled it by

xelatex -shell-escape mintedcheck.tex

the compilation went into an endless loop. Here it is up to the point where I stopped it by ctrl-c

$ xelatex -shell-escape mintedcheck.tex                                         
This is XeTeX, Version 3.141592653-2.6-0.999993 (MiKTeX 21.2 Portable)          
entering extended mode                                                          
(mintedcheck.tex                                                                
LaTeX2e <2020-10-01> patch level 4                                              
L3 programming layer <2021-02-18> xparse <2020-03-03>                           
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/base\article.cls              
Document Class: article 2020/04/10 v1.4m Standard LaTeX document class          
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/base\size10.clo))             
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/minted\minted.sty             
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/graphics\keyval.sty)          
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/kvoptions\kvoptions.sty       
(C:\Program Files\miktex-21.2\texmfs\install\tex/generic/ltxcmds\ltxcmds.sty)        
(C:\Program Files\miktex-21.2\texmfs\install\tex/generic/kvsetkeys\kvsetkeys.sty))   
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/fvextra\fvextra.sty           
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/base\ifthen.sty)              
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/etoolbox\etoolbox.sty)        
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/fancyvrb\fancyvrb.sty)        
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/upquote\upquote.sty           
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/base\textcomp.sty))           
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/lineno\lineno.sty))           
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/latex-tools\calc.sty)         
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/latex-tools\shellesc.sty)     
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/ifplatform\ifplatform.sty     
(C:\Program Files\miktex-21.2\texmfs\install\tex/generic/pdftexcmds\pdftexcmds.sty   
(C:\Program Files\miktex-21.2\texmfs\install\tex/generic/infwarerr\infwarerr.sty)    
(C:\Program Files\miktex-21.2\texmfs\install\tex/generic/iftex\iftex.sty))           
(C:\Program Files\miktex-21.2\texmfs\install\tex/generic/catchfile\catchfile.sty     
(C:\Program Files\miktex-21.2\texmfs\install\tex/generic/etexcmds\etexcmds.sty))     
(C:\Program Files\miktex-21.2\texmfs\install\tex/generic/iftex\ifluatex.sty))        
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/xstring\xstring.sty           
(C:\Program Files\miktex-21.2\texmfs\install\tex/generic/xstring\xstring.tex))       
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/framed\framed.sty)            
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/float\float.sty))             
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/xcolor\xcolor.sty             
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/graphics-cfg\color.cfg)       
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/graphics-def\xetex.def))      
(C:\Program Files\miktex-21.2\texmfs\install\tex/latex/l3backend\l3backend-xetex.def 
<truncated> (Full listing as file below)                             

Any ideas?

muzimuzhi commented 3 years ago

@LarsMalmsteen The truncated log shows no clue about the endless loop. Try waiting for a bit more seconds before pressing ctrl-c? I have no access to Windows OS, hence it's highly possible I can't help. You may post the question to tex.stackexchange.com.

tugkan0153 commented 3 years ago

@muzimuzhi Alright, it 's not an endless loop per se. Let's call it neverending chunks of code. If I leave it for an hour it'll keep on chunking code for an hour. Here is the minted_control log file

This chunk of code is very likely be caused by some setup issues on Windows 7+. As a wild guess, Windows path name format or the way the Windows command line handles the variables might be cause a line inside the minted.sty go wrong. I might eventually ask it on SO of course but I have a feeling that we might solve it here.

muzimuzhi commented 3 years ago

@LarsMalmsteen Unfortunately, the newly attached stdout lines were all latex3-related staffs, but no minted-related. Guess you could i) run the testing example for ~10s, ii) press ctrl-c, iii) attach the log file, rather than copy-and-paste the stdout lines. Also I suggest to edit the previous two comments to convert stdout lines into attached files, just to save the scroll bar from growing too short.

tugkan0153 commented 3 years ago

@muzimuzhi I don't know what is meant by runing the testing example for "~10s" What is exactly ~10s ? I've edited my previous post so that they are shorter and one of it contains the log file (98KB)

muzimuzhi commented 3 years ago

What is exactly ~10s ?

~10s means "about ten seconds", where 1 second = 1/60 minute. Sorry for the fuzzy meaning.

Here is the minted_control log file

This log file stopped at the middle stage of executing \IfFileExists {\minted@jobname .aex}{\ShellEscape {del \minted@jobname .aex}}{}, so the log shown no endless loop ... Perhaps it is the character-per-character filename paring approach (see https://github.com/latex3/latex2e/issues/523) used in previous latex3 versions that caused your problem. That scheme has been changed to a simple and much faster \csname-based one, see https://github.com/latex3/latex2e/issues/523#issuecomment-823541835. The related PR to latex3 was contained in releases since 2021-05-07.

Can you please upgrade latex3 (called l3kernel in MikTeX and try again? Perhaps a latest latex2e (called ltxbase in MikTeX) is also required.

tugkan0153 commented 3 years ago

Oh that's alright. I've upgraded to the miktex-21.6 with the hope that it contains the l3kernel (it was 21.2 before) and re run the check code which I've filed as minted_control.tex This time it ended in a reasonable amount of time, in about 10-15 seconds and it asked (or let's say prompted) \minted@apppathifexits= and I've entered true next to it and in ended up with minted_control.pdf in which just True is written. Here is the log file for MikTex-21.6

When I tried to compile one of my .tex files which uses minted package, namely: xelatex -shell-escape pygmentation_check.tex it stopped by the same usual prompt \minted@apppathifexits= and after I've entered true it prompted again with the message ! Package minted Error: Missing Pygments output \inputminted was probably given a file that does not exist... and I've given x to quit and it quit wo producing the PDF.

muzimuzhi commented 3 years ago

Here is the log file for MikTex-21.6

Looks like the result of executing

for ^%i in (pygmentize.exe pygmentize.bat pygmentize.cmd) do set > minted_control.aex <nul: /p x=^%~$PATH:i>> minted_control.aex

was wrong (starting from line 2126 of the attached log file). From the code comment, https://github.com/gpoore/minted/blob/5d72859d714a6f2f6a42eec524476994d954b960/source/minted.dtx#L1937-L1945

But in your case it seems the file minted_control.aex was not created, hence you saw a prompt \minted@apppathifexits= ... Therefore I suggest to check if your current OS user has the permission to create file/(sub)directory through TeX's \write18 in the directory containing minted_control.tex.

For example do you see a subdir _minted-minted_control? Or can you see a file xxx.tmp after running (with -shell-escape)

\documentclass{article}
\begin{document}
% see https://stackoverflow.com/a/37756874/8590320
\write18{echo.> xxx.tmp}
\end{document}
tugkan0153 commented 3 years ago

@muzimuzhi When I tried the code

\documentclass{article}
\begin{document}
% see https://stackoverflow.com/a/37756874/8590320
\write18{echo.> xxx.tmp}
\end{document}

It didn't create any xxx.tmp file but I think there's a typo at echo.> xxx.tmp because when I enter it directly on ConEmu (my preferred Windows terminal) it didn't create the xxx.tmp either. So I gues it should be echo .> xxx.tmp because it created a xxx.tmp on ConEmu. But the (corrected) one : \write18{echo .> xxx.tmp} didn't create a xxx.tmp It looks like the write18 doesn't function from within the .tex file. If it is a OS permission issue, currently I don't know how to fix it.

muzimuzhi commented 3 years ago

@LarsMalmsteen Apart from the not-created xxx.tmp, can you see a subdir _minted-minted_control in the same directory of minted_control.tex (after running any minted example)? If it exists, what are its contents?

According to https://latexref.xyz/_005cwrite18.html,

The shell_command text is always passed to /bin/sh on Unix-like operating systems, and the DOS command interpreter cmd.exe on Windows. Any different shell set by the user, and the SHELL environment variable, is ignored.

Which terminal is irrelevant, as far as it accepts the same input as cmd.exe does.

It's not the recommended operation, but can you try opening a cmd.exe with "Run as administrator", and execute xelatex -shell-escape?

tugkan0153 commented 3 years ago

@muzimuzhi Ops! Actually I checked if a _minted-minted_control dir was being created in the same folder of minted_control.tex by specially watching out the directory but no dir was created; I've just forgotten to add this in my previous message.

I've tried now opening ConEmu and cmd.exe too, as the administrator and no change in situation, exactly the same error happens. Anyway, I was expecting this because the file permissions in windows 7 are kind of fake

muzimuzhi commented 3 years ago

@LarsMalmsteen So the behavior of no permission to create dir or file (from inside TeX's \write18{...}) is consistent. I think It's time to turn to tex.stackexchange.com or stackoverflow.com.

tugkan0153 commented 3 years ago

@muzimuzhi I've posted a post on tex.stackexchange.com minted package doesn't work on Windows 7 and neither the answer nor the comments didn't help a bit. I was expecting this anyway because it's not a tex nor miktex or tex live issue. It's all about the minted package.

muzimuzhi commented 3 years ago

It's all about the minted package.

@LarsMalmsteen No I disagree. Our discussions since https://github.com/gpoore/minted/issues/280#issuecomment-860526638 have shown that there is a problem, more general than "failed to use minted", in your computer. With -shell-escape, any CMD commands are expected to be successfully executed by \immediate\write18{<cmd>}, and using minted is just a special use case of \write18.

To do further tests, you could find some CMD commands that creates directories or files when executed in cmd.exe, then try it in TeX with

\documentclass{article}
\begin{document}
text
\immediate\write18{<cmds>}
\end{document}

BTW, I just found that the latest MiKTeX doesn't support Win 7 anymore.

MiKTeX for Windows requires one of the following Windows operating systems:

  • Windows 10
  • Windows Server 2016
  • Windows 8/8.1 (all editions except RT)
  • Windows Server 2012

There was already a post in MiKTeX's official support forum asking "Whether support Win7 by MiKTex", and the post received no responses yet.

Other possible resorts:

tugkan0153 commented 3 years ago

@muzimuzhi the CMD commands test code is compiled w.o. errors and produced the PDF file but it didn't create any directory (if \write18{<cmds>} is supposed to create a dir named "cmds")

TeX Live is unpractical because it's over 4GB (the storage space on my Laptop is limited) and the online applications have privacy concerns.

I plan to solve it by myself but I need to know how a TeX package is prepared. I'll do some research.

muzimuzhi commented 3 years ago

TeX Live is unpractical because it's over 4GB

Only a full scheme TeX Live installation takes that much space. Now installing TeX Live over the internet is the preferred way so you don't have to download a mega ISO file, and you can selectively choose which schemes or packages are to be installed. Compared to MiKTeX, the main shortcoming of TeX Live is that it cannot install packages on-the-fly, not the required hardware space.

seb-pau commented 3 years ago

To do further tests, you could find some CMD commands that creates directories or files when executed in cmd.exe, then try it in TeX with

\documentclass{article}
\begin{document}
text
\immediate\write18{<cmds>}
\end{document}

I used this approach to troubleshoot the problem. By compiling

\documentclass{article}
\begin{document}

\makeatletter 
\immediate\write18{echo \@percentchar PATH\@percentchar > tmp.txt}
\makeatother

\end{document}

Which executes echo %PATH% > tmp.txt.

I figured out that my MikTeX install uses it's own PATH variable, which only includes "P:\TeX\MiKTeX 2.9\miktex\bin\x64\" instead of my full PATH variable.

As a quick fix, I got minted to work by copying the pygmentize.exe file to that directory, but I have no clue why MikTeX doesn't use the regular PATH environment.

habamax commented 3 years ago

Have the same issue with TeX Live on win10, pygmentize.exe is in path but:

Package minted Error: You must have `pygmentize' installed to use this package.
habamax commented 3 years ago

Hmm, let me take my words back -- this error I have in vimtex output that uses latexmk.

If I do lualatex -shell-escape test.tex from command line, it compiles without any issues.

muzimuzhi commented 3 years ago

@habamax Sorry I don't use vimtex so I can only guess. Can you try to directly set vimtex with -shell-escape (so the problem is simplified a little bit) and test again? Also personally I suggest to open a new issue next time, since the actual cause, though throws the same error message, varies.

Possibly Related:

habamax commented 3 years ago

I have deleted all aux files and _minte_something directory -- and it works there too.

PeterQiu0516 commented 3 years ago

Thanks you for all your help ^ ^!

Previously I overrode the problem by using Overleaf. 1 year after, I bought myself a new computer and followed the instruction here, which completely solves the problem.

Some suggestions: (1) I am using VS Code as the LaTeX editor, and if you also use some sort of IDE to edit LaTeX, do run them as admin. (2) Do add -shell-escape flag for compiling command. (3) Adding pygmentize.cmd as in the instruction page does help. (4) Using Anaconda to arange depency helps sorting things out.

alihaiderismail commented 2 years ago

I had a similar issue and was pulling my hair out. This seems to be an issue that is wholly unrelated to minted and is more to do with MiKTeX and system setup, given what @seb-pau posted on July 19th. See these issues on the MiKTex project, Path problems in write18-call after miktex-update #786, and PATH instead of Path #926.

I discovered the issue for me was being caused by an outdated version of Clink. See https://tex.stackexchange.com/a/625327/91873 for my solution. Hope this helps others who have stumbled on this thread and have otherwise done everything else right.