6

I have 2 versions of Python on my machine. Version 2.7.10 can be invoked with python, whereas python3 uses 3.5.0 under the hood.

I'd like to use minted with python3, which is why I installed Pygments via pip3. When I compile a LaTeX document that contains minted macros, it can't find the library. I assume minted uses the standard python command and therefore version 2.7.10, which doesn't have Pygments installed.

Is there a way to tell minted to switch to version 3?

EDIT: As pointed out by G. Poore, minted invokes pygmentize. Although which pygmentize points to Pygments under version 3, I tried to set it manually:

\usepackage{minted}
\renewcommand{\MintedPygmentize}{/path/to/pygmentize}

Unfortunately I still get You must have 'pygmentize' installed to use this package with minted 2.1.

beatngu13
  • 897

2 Answers2

4

minted invokes the pygmentize script, which provides a command-line interface to Pygments. If minted can't find pygmentize, then the command-line scripts for Python 3 aren't available, and you probably need to modify your PATH.

G. Poore
  • 12,417
  • Using a Debian-based Docker image with python3 available and pygmentize installed for that interpreter, I ran into this confusing problem. minted mainly works because pygmentize was available, but stuff like autogobble and \inputminted, which call python -c, didnt' work. Ideally, both programs need to be available. The python -> python3 aliasing can be done via symlinking or update-alternatives --install /usr/bin/python python /usr/bin/python3 1 on Debian. I saw the sh: python not found error but had incorrectly assumed it switched to python3 (but it's pygmentize). – Alex Povel Feb 08 '21 at 15:38
4

I figured out that in my particular case TeXShop was causing the error. One must create a symlink within /Library/TeX/texbin to pygmentize (see this answer). Afterwards you can also omit to reset \MintedPygmentize.

beatngu13
  • 897