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 '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
  • 1
    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

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
| improve this answer | |
  • 2
    sudo ln -s $(which pygmentize) pygmentize – jiun Mar 16 '18 at 16:15
  • 1
    @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!

| improve this answer | |

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.