11

I have been using VS Code + Latex Workshop for the last year and so to write up my tex documents however today I tried using the minted package which I have installed in /usr/local/bin/pygmentize

In my preamble I have used the line \usepackage{minted} and when I try to produce my pdf I get this error in my .log file:

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

How do I fix this?

  • you need to install pygmentize in your operating system (it is a python package) you say you installed minted in the pygmentize directory, which would not be right, also you need to use latex with --shell-escape – David Carlisle May 19 '18 at 22:51
  • Requirement already satisfied: Pygments in /Library/Python/2.7/site-packages/Pygments-2.2.0-py2.7.egg (2.2.0) This is what I get after installing , is it in the wrong location? – bigfocalchord May 19 '18 at 23:05
  • you need pygmentize to be on the path so typing pygmentize in the terminal works, I guess that's a mac and I can't help with the details on macos, sorry – David Carlisle May 19 '18 at 23:43
  • @DavidCarlisle Do you know what shell-escape does? and do you know why pygmentize needs it? – Amelio Vazquez-Reina Dec 16 '19 at 19:31
  • yes it allows tex to run external programs, which by default is not allowed. It is a security risk so it is disabled by default. @AmelioVazquez-Reina – David Carlisle Dec 16 '19 at 19:34
  • I am on MacOS and can confirm that running latex/pdflatex with the --shell-escape option does resolve this issue. You can add it to the default latex command in some editors as well (TexShop for example), but this comes with security risk. You should accept the answer provided by @logstar. – osprey Dec 23 '19 at 16:45

1 Answers1

15

You could try @David Carlisle's comment by adding --shell-escape to the compiling commands in the preference of LaTeX Workshop, like the following:

// in USER SETTINGS add the following
"latex-workshop.latex.tools": [
    {
        "name": "latexmk",
        "command": "latexmk",
        "args": [
            "--shell-escape", // added arg to default
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "-pdf",
            "%DOC%"
        ]
    },
    {
        "name": "pdflatex",
        "command": "pdflatex",
        "args": [
            "--shell-escape", // added arg to default
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOC%"
        ]
    },
    {
        "name": "bibtex",
        "command": "bibtex",
        "args": [
            "%DOCFILE%"
        ]
    }
]

This worked for me with VS Code 1.24.1 and LaTeX Workshop 5.5.1.

logstar
  • 257
  • 1
  • 6
  • Thanks -- I know a number of people who found and read this answer are wondering the same question (other sites link to this answer): How did you know what else to add to this JSON object with settings? (the original question was only asking for --shell-escape but you added much more here). – Amelio Vazquez-Reina Dec 16 '19 at 19:29
  • @AmelioVazquez-Reina the other settings are not related and wouldn't affect the output. synctex lets you click on the pdf and get back to the code, and interaction and file-line-error affect tex's behaviour on errors. – David Carlisle Dec 16 '19 at 19:52