latex使用minted: Package minted Error: Missing Pygments output

\usepackage[cache=true,outputdir=./out]{minted}导入minted包. 用\begin{minted}, \end{minted}.
编译命令是: xelatex --shell-escape filename.tex.
遇到下面这个报错:

! 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.

要确保这几件事:

  • 能在命令行用python启动python
  • 已经安装了Pygments
  • 命令行可以执行pygmentize命令, 如果这步不行, 需要设置环境变量包含Pygments的binary file所在的path

我已经做了几件事, 可还是不行, 怎么回事.
答案是, \usepackage[cache=true,outputdir=./out]{minted}的这个outputdir需要在命令行再次给出: -output-directory=./out. 也就是用xelatex --shell-escape -output-directory=./out bio_hw3.tex编译.
不再报错.

posted @ 2022-04-30 17:30  Tokubara  阅读(854)  评论(0编辑  收藏  举报