Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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,

share|improve this question
add comment

5 Answers

up vote 11 down vote accepted

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.

share|improve this answer
    
@Konrad Rudolph: Without the fix for \TestAppExists I get TeX asking for \@apppathifexists=, which does not much good! –  Joseph Wright Jul 19 '11 at 8:04
    
@Chan: Just to point out that I'm using TeX Live 2010. I don't think this should make too much difference to the result, although there are occasional differences in file handling between TeX Live and MiKTeX. –  Joseph Wright Jul 19 '11 at 8:06
    
Thank you for your solution. I think I got all the steps set up correctly, except the fix for \newcommand. I wonder where should I add these two lines? inside my .tex or inside the minted.sty. I added in my .tex and I got another error. –  Chan Jul 20 '11 at 2:42
    
I tried out your solution on Ubuntu and it worked perfectly. I still couldn't figure out why it was broken on Windows :(. –  Chan Jul 20 '11 at 4:02
    
@Chan: On my system, I added the \newcommand part in the main .tex file, just before loading minted. That was because my initial trial failed to work, with TeX waiting for some kind of keyboard input. The Pygmentize installation itself went fine, as checked at the Command Prompt using pymgmetize -V. –  Joseph Wright Jul 21 '11 at 6:53
show 7 more comments

The problem might be due to issues with setuptools (for example with UAC).

Here is an installation procedure which is working for me:

  1. Install Python 2.7

  2. Install distribute (replacement for setuptools because it is buggy and no more maintained)

  3. Add C:\Python27\Scripts to your PATH

  4. Install pip: easy_install pip

  5. Install pygments: pip install pygments

These steps create a pygmentize.exe, so there is no need to create the batch file.

share|improve this answer
add comment

Re-installing minted fixed the issue. To uninstall a package in MikTex, go to Package Manager (Admin). Reinstall minted under TexMaker, after that I don't even need the \newcommand\TestAppExists[3]{#2}. Just make sure you add the scripts pygmentize.cmd to the C:\Python27\Scripts\ with the content:

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

Note: The one in the instruction document missed a \ after %PYTHON%. Further, this solution only works under Windows environment, for Linux variants, you have to go with Joseph Wright's solution.

share|improve this answer
add comment

Python 3.4 comes 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:

  1. Install Python 3.4 (PATH can be set during installation).
  2. On Windows, run pip3.exe install Pygments from a command prompt. This will create a pygmentize.exe in the Pythons Scripts directory.
  3. 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.

share|improve this answer
add comment

So this is a bit late, but I got everything to work on Windows 7 and I can compile and create my pdf within TeXworks using MiKTeX. (I apologize for improper formatting. Doing this late at night and have not done this before, but I wanted to type it somewhere before I forget)

  1. Install Python 2.7
  2. Install setuptools-0.6c11.win32-py2.7.exe
  3. Add C:\Python27\Scripts to your PATH (just google how to do this if you don't know how)
  4. Navigate to your Scripts folder and run "easy_install Pygments" in the command prompt
  5. Make a file called "pygmentize.cmd" in the Scripts folder with the contents: @echo off set PYTHONPATH=C:\Python27 %PYTHONPATH%\python.exe %PYTHONPATH%\Scripts\pygmentize %*

As of now, if you run "pdflatex --shell-escape myFileName.tex" in the command prompt it will work. If you want it to work within TeXworks (and I assume other similar programs), you have to make one extra step.

  1. Click edit-->preferences, then go to the Typesetting tab. Click the "+" and add your Scripts directory ("C:\Python27\Scripts")

Now it works! Yay! With this set of steps, the \newcommand\TestAppExists[3]{#2} is not needed.

share|improve this answer
    
Welcome to TeX.sx! –  mafp Apr 16 '13 at 9:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.