1

I am working with LaTeX on Vista using TeXnicCenter 2.0 Alpha 3 (build 1118) having installed MiKTeX 2.8. I want to use code highlighting for Objective-C and read here that the minted package is great. I installed Python 2.7 and pygmentize as told in the minted documentation. I also set the compiler option -shell-escape in TeXnicCenter. The compiler finds the pygmentize script but the following error occurs.

File "C:\Python27\Scripts\pygmentize.exe", line 1 SyntaxError: Non-ASCII character '\x90' in file C:\Python27\Scripts\pygmentize.exe on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details! LaTeX Error: File `Test.out.pyg' not found. Type X to quit or to proceed, or enter new name. (Default extension: out.pyg) Enter file name: ! Emergency stop.

I cannot figure out how to fix the problem. I tried saving the tex file as ANSI or UTF-8. The only additions I made to the tex file are the package include

\usepackage{minted}

and this simple example from the minted documentation.

\mint{python}|import this|

Community
  • 1
  • 1
JJD
  • 50,076
  • 60
  • 203
  • 339
  • This sounds as if the error is directly in the `pygmentize.exe`. Can you try running the application directly from the command line? If this yields a similar error, there’s very likely a bug i Pygments. – Konrad Rudolph Sep 12 '10 at 14:30
  • Your suggestion sounds right. When I run the command pygmentize from the Windows cmd in any directory it already states the same error. I guess something is wrong with the pygmentize.cmd script I created. > @echo off set PYTHONPATH=C:\Python27 %PYTHONPATH%\python.exe %PYTHONPATH%\Scripts\pygmentize.exe %* – JJD Sep 12 '10 at 15:04

1 Answers1

5

The minted documentation is outdated: newer versions of Pygments apparently include a Windows executable pygmentize.exe (unfortunately, their Trac is currently offline so I can’t look up the relevant revision which changed that).

This means that the fix mentioned in the documentation should be redundant. Therefore, try the following steps:

  1. Remove the pygmentize.cmd script entirely (best not delete it yet – just rename it). Try if minted now works.
  2. If that doesn’s work, put the following into the pygmentize.cmd:

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

    i.e. don’t invoke the *.exe file via the Python interpreter.

Unfortunately, I can’t test this now since I don’t have Windows here. But one of the options should work.

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
  • 1
    I love it! Konrad, you made my day. It works when I put the pygmentize.cmd file in C:\Program Files\MiKTeX 2.8\miktex\bin since MiKTex somehow does not realize C:\Python27\Scripts although its included in the PATH variable. Thank you so much. – JJD Sep 12 '10 at 15:46
  • Konrad great solution! Im running on Windows 7 64 bit, all you need is to check if the PATH variable for windows has C:\Python27 in it and then use your pygmentize.cmd with the python.exe. – Sam Feb 22 '12 at 18:22