gpoore / minted

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

Error : Missing Pygments Output #396

Closed jyuyangma closed 22 hours ago

jyuyangma commented 2 days ago

Dear Author,

I encountered the following message when I am writing latex in Visual Studio Code:

Package minted: Missing Pygments output; \inputminted was
probably given a file that does not exist--otherwise, you may need 
the outputdir package option, or may be using an incompatible build tool,
or may be using frozencache with a missing file.

I am using MikTex which is installed on the Window 11 system. I have googled a lot for this issue, yet I haven't figured it out. I have checked the accessibility of Pygmentize.exe, and it works fine. I have also try to run the pdflatex through terminal instead of latex-workshop in VSCode, the error still remains.

My code in terminal is as following: pdflatex --shell-escape -out-directory=temp FILENAME.tex

The weird thing is that, for the same latex file, I can run it on my Macbook, but it doesn't work on my windows machine. Could you please help me on this issue. Thank you.

jyuyangma commented 2 days ago

Besides, when I imported the minted package, I have emphasized the output location by setting

\usepackage[outputdir=temp]{minted}

I have also tried the option [cache=false]: the PDF generated, but the code part did't show.

gpoore commented 1 day ago

Try -output-directory instead of -out-directory. I'd suggest trying to get everything working in the terminal before trying VS Code. You should see if pygmentize -V works in the terminal, if you haven't already; Pygments may be installed but not on PATH.

jyuyangma commented 1 day ago

Try -output-directory instead of -out-directory. I'd suggest trying to get everything working in the terminal before trying VS Code. You should see if pygmentize -V works in the terminal, if you haven't already; Pygments may be installed but not on PATH.

Thank you Geoffery, I have checked the installation of Pygmentize, and it seems it works well, as it return the following message after I ran pygmentize -V:

Pygments version 2.17.2, (c) 2006-2023 by Georg Brandl, Matthäus Chajdas and contributors.

I have also tried to compile the tex file through terminal, yet the problem remains:

pdflatex -shell-escape -output-directory=temp  -aux-directory=temp -synctex=1 -interaction=nonstopmode .\hw1_solution.tex
gpoore commented 1 day ago

I'd suggest trying in the terminal without -output-directory and -aux-directory, and without outputdir=temp in \usepackage to see if you can get it working at all.

jyuyangma commented 1 day ago

I'd suggest trying in the terminal without -output-directory and -aux-directory, and without outputdir=temp in \usepackage to see if you can get it working at all.

Just tried it. It still doesn't work.

I just checked the .log file, not sure if the following message can help or not:

(C:\Program Files\MiKTeX\tex/context/base/mkii\supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (C:\Program Files\MiKTeX\tex/latex/epstopdf-pkg\epstopdf-base.sty
(C:\Program Files\MiKTeX\tex/latex/00miktex\epstopdf-sys.cfg))
(C:\Program Files\MiKTeX\tex/latex/amsfonts\umsa.fd)
(C:\Program Files\MiKTeX\tex/latex/amsfonts\umsb.fd)
(temp/_minted-hw1_solution/default.pygstyle)Error: cannot open outfile: [Errno 2] No such file or directory: 'temp/_minted-hw1_solution/8B5752CDB0380AF97F268D0028A9DD0BBC1C8690AB8D0915C14E1582D594347A.pygtex'

! Package minted Error: Missing Pygments output; \inputminted was
probably given a file that does not exist--otherwise, you may need
the outputdir package option, or may be using an incompatible build tool,
or may be using frozencache with a missing file.

See the minted package documentation for explanation.
Type  H <return>  for immediate help.
 ...
jyuyangma commented 23 hours ago

I'd suggest trying in the terminal without -output-directory and -aux-directory, and without outputdir=temp in \usepackage to see if you can get it working at all.

I just ran the same file on my MacBook again, it worked and I checked the files in the folder temp. It seems there are something wrong with the Pygmentize. On my MacBook, after I compile the tex file, in the folder -minted-FILENAME, there are 3 other files (I guess they are generated by Pygmentize) except for the default.pyg. However, on my windows computer, there is only one file default.pyg. I guess here is the reason.

gpoore commented 23 hours ago

The log you posted refers to temp, so it appears that -output-directory or something similar is still in use.

Do the folders temp and temp/_minted-hw1_solution exist? If not, you might create them and try again. You are getting a Python error message from Pygments that it cannot create output files, and this might be due to the folders not already existing for some reason.

jyuyangma commented 23 hours ago

The log you posted refers to temp, so it appears that -output-directory or something similar is still in use.

Do the folders temp and temp/_minted-hw1_solution exist? If not, you might create them and try again. You are getting a Python error message from Pygments that it cannot create output files, and this might be due to the folders not already existing for some reason.

Yes, both of these folders exist. As I replied above, I think the error is caused by pygmentize, which doesn't generate some files on my Window machine. I am looking into it.

jyuyangma commented 22 hours ago

Finally, I fixed it. I uninstalled Python which I downloaded from the Microsoft Store, and I downloaded a new one from Python.org. I have reinstalled all the packages including Pygmentize. Now it works.