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|
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:
pygmentize.cmd
script entirely (best not delete it yet – just rename it). Try if minted
now works.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.