How to install syntax highlight package minted on Windows 7?
Python 3.4 and newer come with the package manager pip
already included:
http://docs.python.org/3.4/whatsnew/3.4.html
Setting up minted
+Pygments
has therefore become very easy:
- Install the latest Python 3.x (PATH can be set during installation).
- From a normal command prompt, run
python -m pip install -U pygments
. This will create apygmentize.exe
in the Pythons Scripts directory. - You are done. Using
\usepackage{minted}
in.tex
files should now work.
Of course, pdfLaTeX (or whatever engine/format you use) still has to be called with the -shell-escape
option.
On my Windows 7 system, the following got things working:
- Download and install Python 2.7.2
- Download and install distribute
- Add
C:\Python27\Scripts
to the Windows path (I also addedC:\Python27
for general convenience) - At the Command Prompt, do
easy_install Pygmentize
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.
The problem might be due to issues with setuptools (for example with UAC).
Here is an installation procedure which is working for me:
Install Python 2.7
Install distribute (replacement for setuptools because it is buggy and no more maintained)
Add
C:\Python27\Scripts
to your PATHInstall pip:
easy_install pip
Install pygments:
pip install pygments
These steps create a pygmentize.exe
, so there is no need to create the batch file.