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



    def __init__(self, x, y): 



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:

Is there pygmentize?

Judging from that there is Pygmentize on my mac?!

  • 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
    Commented 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
    Commented Mar 14, 2012 at 15:37
  • 3
    If you want to avoid the terminal then it's best to use a TeX only solution such as the listings package.
    – qubyte
    Commented 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 ! Commented Mar 14, 2012 at 18:05
  • My test works fine, but pygmentize is in /usr/local/bin
    – egreg
    Commented Mar 14, 2012 at 18:57

5 Answers 5


Write a file path.tex containing exactly this:



\input|"echo $PATH"


Is there pygmentize?

\input|"which pygmentize"


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

  • I added the results I got to my opening post!
    – Zwähnia
    Commented 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
    Commented Mar 14, 2012 at 17:10
  • @Zwähnia Would you please add a minimal example to your question?
    – egreg
    Commented 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!!! Commented May 25, 2013 at 1:45

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
    Commented Nov 27, 2013 at 20:56

The OP reports the following error message:

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

The first thing to do is to make sure that Pygments is installed on your machine (the OP has already done this). Enter the following into a terminal:

python3 -m pip show Pygments
which pygmentize

# To install Pygments:
# python3 -m pip install Pygments

On a recent MacOS, it is likely that you encounter the above error, even if Pygments is installed. This is because GUI applications such as TeXShop or Texmaker are not able to see your environment variables (unless they are launched from a Terminal). As a consequence, the PATH environment variable is not the same for GUI Applications. Unless pygmentize is installed under /usr/local/bin, the GUI will not be able to localize the command-line utility.

Workaround 1: Add a symbolic link to /usr/local/bin.

ln -s /path/to/pygmentize /usr/local/bin/pygmentize

Workaround 2: Run your your TeX editor from a Terminal. For TeXShop:

# Or with path to source file
/Applications/TeXShop.app/Contents/MacOS/TeXShop path/to/tex/file.tex

Workaround 3: Use launchctl to set GUI-visible environment variables. I am not so versed with launchctl, which is why I just provide this link to a related post.

I am not sure if this workaround still works, as the way launchctl works has changed under newer macOS, see here.

  • 1
    +1 My previous fix for this was to put the symlink in /Library/TeX/texbin but this has the disadvantage of being deleted when I install each year's new MacTeX distribution. It never occurred to me to put the symlink in /usr/local/bin. My pygmentize is installed with conda so I just did ln -s ~/miniconda3/bin/pygmentize /usr/local/bin/pygmentize and everything works fine. Commented Sep 28, 2022 at 17:06

My solution using TexMaker on macOS Monterey was:

  1. install the package using PiP3 (pip3 install pygments)
  2. optional: update pip as suggested when installing the package (I have Xcode): /Applications/Xcode.app/Contents/Developer/usr/bin/python3 -m pip install --upgrade pip
  3. add the path of python 3.x to sudo nano /etc/paths (in my case it was /Users/neogene/Library/Python/3.9/bin/), because "which pygmentize" was not detecting the app without setting this new path added (note: close and restart the terminal).
  4. Add to TexMaker config the -shell-escape to both the commands(Latex and pdflatex) before last parameter %.tex
  5. Add the same path to the field "Add to PATH" in the same settings windows pointing to /Users/neogene/Library/Python/3.9/bin/

Maybe the path addition to the etc/paths is useless but without it in terminal I was unable to find the binary.

The TexMaker setup for MAC


Use which pygmentize to find the path for pygmentize first in Mac OS terminal, and then copy it to /usr/local/bin.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .