0

I am currently trying to resolve the issue of outputting my Python code in my LaTex document via the minted package. Originally, I ran into the issue of the "shell-escape flag" Error which, after resolution, gave me the "catchfile" Error. I finally resolved this by eliminating the spaces in my document name, however now I am stuck with the "`Pygmatize'" Error and I am at a loss for what to do here.

I have looked all over the internet for what others have done in the past and have attempted to do the same as them, to no avail. I've installed pygments from the terminal after having to install pips – I can check the version in the terminal and it's saying I have version 2.4.2. I also installed minted and can find the folders using finder. I've created the /~Library/texmf/tex/latex tree and tried putting in the relevant minted.sty file in there so that LaTex can apparently find/read that. I've checked to see that I have minted installed via TeX Live Utility (it's installed).

I have no clue what to do after this. LaTex still won't compile my document and is still giving me the "`Pygmatize'" Error. I've spent way too long trying to find a solution here and just want this document to compile.

I would really appreciate any help with this.

9
  • 1
    Well while I understand that you are frusted as it is nobody can answer your question. It is completly unclear what you actually did, and what you have installed (and e.g. what has version 2.4.2). And your question contains a lot of typos. But don't start to move manually files around: this will only put your system in a even more unclear state. You have minted.sty - after all it gives an error message - so there is no need to install it again. What do you get on a terminal from pygmentize --help? Nov 4, 2019 at 11:57
  • @Ulrike Fischer, thank you for the response. Here is the first terminal output when I input "pygmentize --help": Usage: /Library/Frameworks/Python.framework/Versions/2.7/bin/pygmentize [-l <lexer> | -g] [-F <filter>[:<options>]] [-f <formatter>] [-O <options>] [-P <option=value>] [-s] [-v] [-x] [-o <outfile>] [<infile>] Nov 4, 2019 at 14:33
  • /Library/Frameworks/Python.framework/Versions/2.7/bin/pygmentize -S <style> -f <formatter> [-a <arg>] [-O <options>] [-P <option=value>] /Library/Frameworks/Python.framework/Versions/2.7/bin/pygmentize -L [<which> ...] /Library/Frameworks/Python.framework/Versions/2.7/bin/pygmentize -N <filename> /Library/Frameworks/Python.framework/Versions/2.7/bin/pygmentize -H <type> <name> /Library/Frameworks/Python.framework/Versions/2.7/bin/pygmentize -h | -V Highlight the input file and write the result to <outfile>. Nov 4, 2019 at 14:34
  • pigmentize -V should give nothing, the name is pygmentize -V. But it looks as if it is installed. Now go in the same terminal to the folder of your tex-document with the minted test and type in the terminal pdflatex --shell-escape name-of-the-tex-file. Nov 4, 2019 at 14:36
  • So sorry, that's my bad. I have been inputting "pygmentize -V" to the terminal. So use the terminal to get to the tex file I'm trying to use minted with? Nov 4, 2019 at 14:40

2 Answers 2

1

Here is a recipe using Python 3.9 and MacTeX 2022 in April 2022. YMMV.

  • Install a virtual environment for your favorite Python version (python -m venv ~/.py39venv).
  • Switch to the new venv (source ~/.py39venv/bin/activate).
  • Install pygments (pip install pygments).
  • Confirm that the last pip installed the command pygmentize (which pygmentize should point to ~/.py39venv/bin/pygmentize).

From then on:

  • Switch to the new venv (source ~/.py39venv/bin/activate).

  • Write some latex + code:

    \documentclass{article}

    \usepackage{minted}

    \begin{document}

    \begin{minted}{c}

    int main() {

     printf("hello, world");
     return 0;
    

    }

    \end{minted}

    \end{document}

and run pdflatex (pdflatex -shell-escape hello).

0

It seems with some help I found the solution:

I just copied and pasted the "pygmentize" executable unix from /Library/Frameworks/Python.framework/Versions/2.7/bin to /usr/local/bin and it seems to work just fine now.

You must log in to answer this question.

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