I followed the instruction to install pygmentize
in order to use syntax highlight in Latex environment, however TexMaker always produces an error says pygmentize
is not found. I then tested to run the .cmd file itself using command prompt and the system says:
C:\Python27\Scripts>pygmentize.cmd
C:\Python27\python.exe: can't open file 'C:\Python27\Scripts\pygmentize': [Errno
2] No such file or directory
I added path variable for both directories: C:\Python27
and C:\Python27\Scripts
. Within C:\Python27\Scripts
, there are two files:
- pygmentize.exe
- pygmentize.cmd
Where the content of pygmentize.cmd
is as follows:
开发者_如何学Python@echo off
set PYTHONPATH=C:\Python27
%PYTHONPATH%\python.exe %PYTHONPATH%\Scripts\pygmentize %*
The original instruction doesn't contain a \
after %PYTHONPATH%
, I added because the I realize the error message is kinda odd when it says C:\Python27Scripts\python.exe
.
So my question is, why doesn't the Tex system recognize the executable pygmentize
? Following an instruction from a SO from https://tex.stackexchange.com/questions/23458/how-to-install-syntax-highlight-package-minted-on-windows-7, I added a line:
\newcommand\TestAppExists[3]{#2}
in my .tex file and it worked only under Ubuntu. So what's the purpose of the .cmd file in this case?
cmd.exe
will prefer .exe to .cmd when choosing which pygmentize
to execute, all else begin equal. python.exe
will perform no magic at all and will not know what to make of C:\Python27\Scripts\pygmentize
unless a file with that exact name exists.
精彩评论