[Tex/LaTex] How to install syntax highlight package minted on Windows 7

installingmiktexmintedwindows

I followed the instruction from this link: http://tug.ctan.org/tex-archive/macros/latex/contrib/minted/

enter image description here

Firstly, I install Python 2.7, then create a folder named Scripts in the directory:

C:\Python27

So I got C:\Python27\Scripts
Then I create a file named pygmentize.cmd with the content:

@echo off
set PYTHONPATH=C:\Python27
%PYTHONPATH%\python.exe %PYTHONPATH%Scripts\pygmentize %*

At this point, I already set the path environment variable to C:\Python27 and C:\Python27\Scripts.
Next I installed setuptools-0.6c11.win32-py2.7.exe (md5) from http://pypi.python.org/pypi/setuptools
And install Pygments with the following command

easy_install Pygments

Next I include the line \usepackage{minted} to let TexMaker do the installation.

Inside TexMaker, I also change the PdfLaTex option to:
pdflatex -shell-escape -interaction=nonstopmode %.tex

Then I tried out a simple example:

\documentclass[12pt,letterpaper]{article}
\usepackage[latin1]{inputenc}
\usepackage[left=1in,right=1in,top=1in,bottom=1in]{geometry} 
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{minted}

\begin{document}
    \begin{minted}{python}
    def boring(args = None):
    pass
    \end{minted}
\end{document}

And the compiler generated these error:

!Emergency stop.<read 2> \TestAppExists{pygmentize}
!==> Fatal error occured, no output PDF file produced!

I guessed the pygmentize was not installed properly so TexMaker wasn't able to run it. I read the instruction over, and couldn't figure out what could cause these errors? Has anyone done it before could share me some lights?

Thank you,

Best Answer

On my Windows 7 system, the following got things working:

That is it install-wise: the current Pygmentize does come with a Windows executable. You can test this by doing pygmentize -V at the Command Prompt.

What I then found is that the test that minted uses for Pygmentize on Windows is broken. So I used the lines

\newcommand\TestAppExists[3]{#2}
\usepackage{minted}

to bypass the test (this basically forces the TRUE branch). The example document then compiles fine.