8

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?

6
  • 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 May 19, 2018 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? May 19, 2018 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 May 19, 2018 at 23:43
  • @DavidCarlisle Do you know what shell-escape does? and do you know why pygmentize needs it? Dec 16, 2019 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 Dec 16, 2019 at 19:34

1 Answer 1

13

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.

2
  • 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). Dec 16, 2019 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. Dec 16, 2019 at 19:52

You must log in to answer this question.

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