I am using TexShop on mac OS X 10.11.1 and I'm trying to output some Python code inside my LaTeX document.

Here is an example of a document I would want to produce :



    def __init__(self, x, y): 



My LaTeX compile command is pdflatex --file-line-error --synctex=1 --shell-escape --interaction=nonstopmode.

When the command is run directly from the terminal, it works fine. But whenever I try to compile the document from TexShop, I get the following error :

 sh: /Library/TeX/texbin/pygmentize: cannot execute binary file

I also got this error previously :

sh: /Library/TeX/texbin/pygmentize: access denied

I have Python installed, minted package up to date, pygmentize installed and located at ~/anaconda/bin/pygmentize, with symbolic links the following directories : /usr/local/bin/, /usr/local/texlive/2015/bin/x86_64-darwin/ and /Library/Tex/texbin/.

Now, what can I do to get minted to work

By the way, if I run this test file



\input|"echo $PATH"


Is there pygmentize?

\input|"which pygmentize"


I get

Is there pygmentize?
  • Apparently, TexShop looks for pygmentize at the wrong location.
    – jarauh
    Nov 20, 2015 at 16:55
  • I don't think so since the error refers to the right location of the pygmentize file (/Library/TeX/texbin/pygmentize). The error would be different I suppose if the file was not found. Nov 20, 2015 at 18:40
  • 1
    Ok, found it. I replaced the symbolic link in /Library/Tex/texbin/ by an actual copy of pygmentize and it works fine! Nov 20, 2015 at 18:50
  • How do you add /Users/... to your PATH? TeXShop is not starting a login shell so .profile (or .bash_profile) isn't executed. A standard place for placing application like pygmentize is in /usr/local/bin. Jun 1, 2016 at 17:31
  • I wonder if here an answer explaining why this is needed might be useful?
    – Joseph Wright
    Aug 4, 2021 at 7:04

2 Answers 2


I had the same problem and it took me a while until I realized it was TeXShop causing all the trouble. Like you already mentioned, you need a reference to pygmentize within /Library/TeX/texbin, but it's sufficient to create a symlink instead of a copy:

sudo ln -s "$(which pygmentize)" /Library/TeX/texbin/pygmentize
  • 2
    sudo ln -s $(which pygmentize) pygmentize
    – jiun
    Mar 16, 2018 at 16:15
  • 1
    @jiun Thanks, will adapt the answer accordingly.
    – beatngu13
    Mar 16, 2018 at 18:59
  • I'd used command -v as which isn't really reliable like this (although it's very commonly used)
    – Joseph Wright
    Aug 4, 2021 at 7:04
  • The symbolic link has saved my night on macOS/MacTeX too, thank you!
    – unDavide
    May 10, 2023 at 17:59

In my case, I had pygments installed, but I discovered later that is was related with the python 3 version and I believe that TexShop was trying to use the python 2 version. So I installed python 2 using brew and pigments using pip2. It worked!

You must log in to answer this question.

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