22

I am using texmaker on a Mac and I tired to use the minted package with this code

\documentclass[12pt,A4]{article}
\usepackage{minted}
\begin{document}

\begin{minted}{python}

    def __init__(self, x, y): 
        self.x=x
        self.y=y

\end{minted}

\end{document}

but when compiling my code I get the following error:

! Package minted Error: You must have `pygmentize' installed to use this package

However I actually did install the package as described using

sudo easy_install Pygments

I even tried restarting. Still getting the same error.

I really don't see how to fix this error, can someone help me?

When creating the pdf as suggested by egreg the resulting pdf looks like this:

/Library/Frameworks/Python.framework/Versions/2.7/bin
/opt/local/bin
/opt/local/sbin
/opt/local/bin
/opt/local/sbin
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/usr/texbin
/usr/X11/bin
Is there pygmentize?
/Library/Frameworks/Python.framework/Versions/2.7/bin/pygmentize

Judging from that there is Pygmentize on my mac?!

7
  • Do you have pygmentize in your $PATH? Open a terminal and try whether pygmentize is resolved. If not, locate it on your hard drive and set the $PATH accordingly. That may resolve your problem.
    – ilpssun
    Mar 14, 2012 at 15:10
  • if i do 'echo $PATH' I get '/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin' I have no idea what that means, sorry I'm not so much into using the terminal...
    – Zwähnia
    Mar 14, 2012 at 15:37
  • 2
    If you want to avoid the terminal then it's best to use a TeX only solution such as the listings package.
    – qubyte
    Mar 14, 2012 at 16:11
  • 1
    Works fine here but python is here : /Library/Python and pygmentize is here : /usr/local/bin/pygmentize. Perhaps you can create a symbolic link into /usr/local/bin/. I don't work with /opt (macport) because we get always this kind of problem ! Mar 14, 2012 at 18:05
  • My test works fine, but pygmentize is in /usr/local/bin
    – egreg
    Mar 14, 2012 at 18:57

2 Answers 2

20

Write a file path.tex containing exactly this:

\catcode`:=\active
\def:{\par}

\parindent0pt\tt

\input|"echo $PATH"

\bigskip

Is there pygmentize?

\input|"which pygmentize"

\bye

and run from the Terminal the command

pdftex --shell-escape path

You'll see in the produced path.pdf file what pdftex sees as PATH. If there's a path after "Is there pygmentize?" you'll be OK.

Now it's only a question of telling Texmaker that you want to execute external programs such as pygmentize: go to the "Preferences" menu in Texmaker and choose the "Commands" tab. In line next to "PdfLaTeX" there should be

"/usr/texbin/pdflatex" -synctex=1 -interaction=nonstopmode %.tex

Change it into

"/usr/texbin/pdflatex" -synctex=1 -shell-escape -interaction=nonstopmode %.tex

Beware that this opens some security issues, so remove -shell-escape when typesetting documents you get from non trusted sources.

A safer way could be to define a "User command": go to the menu User > User Commands > Edit User Commands and in the upper space write something such as "pdftex-shell-escape"; in the lower space write the string above. You'll have a shortcut for using the shell escape only when you choose to, by pressing Alt+Shift+F1

4
  • I added the results I got to my opening post!
    – Zwähnia
    Mar 14, 2012 at 16:54
  • I already had it like that, so this is not the error. (Still I deleted what I had copied your line in there, tried and am still getting the same error)
    – Zwähnia
    Mar 14, 2012 at 17:10
  • @Zwähnia Would you please add a minimal example to your question?
    – egreg
    Mar 14, 2012 at 18:05
  • @egreg I just spent three hours trying to get minted working on an old TeXLive 2010 on an old OpenBSD 5.1. As soon as I added -interaction=nonstopmode to -shell-escape thing went without a glitch in-spite of the fake warning that I do not have pygmentize (which was B.S. of course). Sir you really rock when it comes to TeX. Thank you so much!!! May 25, 2013 at 1:45
9

I just encountered the same issue and copying pygmentize from /Library/Frameworks/Python.framework/Versions/2.6/bin/pygmentize to /usr/local/bin resolved the problem for me.

1
  • This was it. /usr/local/bin/pygmentize was not being updated. easy_install Pygments showed Installing pygmentize script to /usr/local/share/python so I copied that file over /usr/local/bin/pygmentize and it all worked.
    – Kalle
    Nov 27, 2013 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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