gpoore / minted

minted is a LaTeX package that provides syntax highlighting using the Pygments library. Highlighted source code can be customized using fancyvrb.
1.74k stars 126 forks source link

Message "you must have pygmentize installed" while Pygments is already installed #231

Closed bjce closed 5 years ago

bjce commented 5 years ago

I'm try to use the minted package in latex to display code in latex document. From Texstudio, I get an error message "you must have pygmentize installed to use this package". However, if I type pip3 install pygments I get Requirement already satisfied: pygments in /usr/local/lib/python3.7/site-packages (2.3.1) which means that pip3 has installed it on the machine

What am I doing wrong?

Thank you very much!

NobbZ commented 5 years ago

Can you call the pygmentize executable? It needs to be in your PATH that minted can find it.

bjce commented 5 years ago

Thank you very much for your quick answer @NobbZ.

So from Pyhton3 i get the following message:

>>> import sys
>>> sys.path
['', '/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', 
'/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7', 
'/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', 
'/Users/mymac/Library/Python/3.7/lib/python/site-packages', '/usr/local/lib/python3.7/site-packages', 
'/usr/local/Cellar/numpy/1.15.4_1/libexec/nose/lib/python3.7/site-packages']

how can I find and call the pygmentize executable? Sorry for the basic question

mbaz commented 5 years ago

Just call pygmentize from the command line.

$ pygmentize -V
Pygments version 2.3.1, (c) 2006-2017 by Georg Brandl.
$
bjce commented 5 years ago

ok thank you! I get the following (copy carbon of your output)

$ pygmentize -V
Pygments version 2.3.1, (c) 2006-2017 by Georg Brandl.
mbaz commented 5 years ago

Are you running Latex with the -shell-escape option? Without it, Latex can't call outside programs. I don't use TexStudio, but it must have an option to let you configure options passed to the latex engine.

bjce commented 5 years ago

ok I found the answer:

you have to run the following line in the .tex file:

% !TeX TXS-program:compile = txs:///pdflatex/[--shell-escape]

Many thanks for your answers

intractabilis commented 1 year ago

I run LaTeX with -shell-escape and still have this problem. LuaHBTeX, Version 1.15.0 (TeX Live 2022). pygmentize is installed, in the PATH, and is runnable from command line. It seems -shell-escape like has no effect:

sh: -c: line 1: syntax error near unexpected token `('
sh: -c: line 1: `which pygmentize && mylatexfile(prev).aex'

The command line to compile was

lualatex  -shell-escape -synctex=1 -interaction=nonstopmode -file-line-error -recorder  "mylatexfile(prev).tex"
muzimuzhi commented 1 year ago

@intractabilis I would suggest to open a new issue rather than commenting under a closed one. Same error message may be caused by different reasons.

It seems your issue is caused by the ( and ) in mylatexfile(prev).tex, which hold special meaning for the shell. \minted@jobname need to be quoted as well, like what have been done to pygmentize command-line options in https://github.com/gpoore/minted/commit/25e1f300159c3e7848026688415141508248d113.

intractabilis commented 1 year ago

I am going to check first if it is a luatex's problem. I have a suspicion xelatex will work.

HolgerGerhardt commented 10 months ago

I was facing the same issue: Compiling with LuaLaTeX from the command line worked but it did not when I used TeXstudio. The solution was to tell TeXstudio the path to the pygmentize binary (in my case, /Library/Frameworks/Python.framework/Versions/3.11/bin) in the TeXstudio Preferences, section “Build”, subsection “Additional Search Paths”, field “Commands ($PATH)”.

In other words, it seems that TeXstudio does not access the shell’s $PATH variable.