# Pygmentize not working properly with minted package in TexShop on OS X

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 :

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[francais]{babel}
\usepackage{minted}
\begin{document}

\begin{minted}{python}

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

\end{minted}

\end{document}


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

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

\parindent0pt\tt

\input|"echo $PATH" \bigskip Is there pygmentize? \input|"which pygmentize" \bye  I get /Users/philippe/anaconda/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /Library/TeX/texbin Is there pygmentize? /Users/philippe/anaconda/bin/pygmentize  • Apparently, TexShop looks for pygmentize at the wrong location. – jarauh Nov 20 '15 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. – le petit prince Nov 20 '15 at 18:40 • Ok, found it. I replaced the symbolic link in /Library/Tex/texbin/ by an actual copy of pygmentize and it works fine! – le petit prince Nov 20 '15 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. – Herb Schulz Jun 1 '16 at 17:31 ## 2 Answers 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

• sudo ln -s \$(which pygmentize) pygmentize` – jiun Mar 16 '18 at 16:15
• @jiun Thanks, will adapt the answer accordingly. – beatngu13 Mar 16 '18 at 18: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!