[Tex/LaTex] Texments/minted not working – Undefined control sequence

errorsminted

I'm trying to add some syntax highlighting to my code and found two packages: texments and minted.
I tried to use them, but I'm getting errors while trying to build. I used following code to test both packages:

\pygment{python}{ print "Hello World!"}

All what I get is errors:


**! Undefined control sequence.**

<argument> \PY
{k}{print} \PY {l+s}{"}\PY {l+s}{Hello World!}\PY {l+s}{"}
l.2 ...PY{l+s}{"}\PY{l+s}{Hello World!}\PY{l+s}{"}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

**! Undefined control sequence.**

<argument> \PY {k}{print} \PY
{l+s}{"}\PY {l+s}{Hello World!}\PY {l+s}{"}
l.2 ...PY{l+s}{"}\PY{l+s}{Hello World!}\PY{l+s}{"}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

**! Undefined control sequence.**

<argument> \PY {k}{print} \PY {l+s}{"}\PY
{l+s}{Hello World!}\PY {l+s}{"}
l.2 ...PY{l+s}{"}\PY{l+s}{Hello World!}\PY{l+s}{"}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

**! Undefined control sequence.**

<argument> ... {l+s}{"}\PY {l+s}{Hello World!}\PY
{l+s}{"}
l.2 ...PY{l+s}{"}\PY{l+s}{Hello World!}\PY{l+s}{"}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
) [6]) [7] (./mk_mall.aux) )

I have pygments installed, version 1.4.

How can I get everything to work?

Best Answer

I would like to share another solution for the same issue which couldn't be solved by Frédéric's answer.

In the process of installing minted (and trying to get it to work), I used one TeX file and different settings for python, pdftex and so on. Even compiling Frédéric's example would lead to undefined control sequences. Cleaning up the subdirectory _minted-FILENAME solved this.