8

I want to use minted package, but when I'm xelatexing in TexStudio, there's an error:

minted: You must have `pygmentize' installed to use this package.

pip seems unable to find pygmentize:

enter image description here

In my C:\Python26\Scripts there are files named pygmentize:

enter image description here

I have followed instructions from here https://tex.stackexchange.com/questions/108661/how-to-use-minted-under-miktex-and-windows-7 where it is suggested to install Pygments which is what I did:

enter image description here

This is my PATH:

C:\Users\Milos\AppData\Roaming\npm;C:\Python26;C:\Python26\Scripts

However it is not working. How should I fix this?

9
  • I have a feeling this is probably off-topic: if the Python set up you have doesn't work in this regard then that's not really a TeX problem! Sep 24, 2014 at 20:49
  • I will check my Win7 rig about this, but can't until tomorrow. Sep 24, 2014 at 20:51
  • I would appreciate that. :) Well, if not here, where could I post the question then? :)
    – Milos
    Sep 24, 2014 at 20:53
  • I guess SuperUser might be the best place: probably if we migrate you'll want to edit it down to drop the TeX angle (which isn't really crucial here). Sep 24, 2014 at 20:54
  • 1
    Did you try closing/reopening TeXStudio? Can you compile from the command line (xelatex filename)?
    – darthbith
    Sep 24, 2014 at 21:26

2 Answers 2

8

I had the exact same problem, but on Windows 10. I will now write a proper answer for future users.

There are 3 things that must be done in order to use the minted package in TeX:

  1. Change your pdflatex output to include -shell-escape,

  2. Make sure pygmentize is installed in your python shell, and most difficultly

  3. Make sure TeX prioritizes the correct PATH.

Solutions:

  1. Go to Options in your preferred TeX editor and change the PdfLaTeX to: whatever it was before and then "-shell-escape %.tex"
  2. Go to your Python Shell, fx Anaconda Prompt if you're using Anaconda as your Python editor. Check if pygmentize is already installed by writing: pygmentize -V. If it brings up your current version, continue to solution 3. If not, type: pip install Pygments. This should install pygmentize in whatever folder your Python editor uses for scripts, which is needed for the next solution.
  3. First, use Windows search to find "pygmentize.exe". Copy the path from the address bar, fx "C:\Users\YourUsernameHere\Anaconda3\Scripts".

    Now use Windows search to find "Advanced System Settings". Clicking on the result should bring you exactly to the "Advanced" tab of the System Settings, if not, go there. There will be a button for "Environment Variables...", click on it.

    Under the "User variables for YourUsernameHere", click on the variable "Path" and then click "Edit...". Create a new path for the copied path from earlier, fx "C:\Users\YourUsernameHere\Anaconda3\Scripts", and then click "Move up" until it is above any TeX related paths.

    Restart your computer. Minted should now work :)

Hope this helps someone in the future save precious time that I wasted myself. Net gain!

1
  • I installed Python via Windows App store, and this is the location where I found my pygmentize.exe: c:\users\myusername\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\Scripts\pygmentize.exe I hope this helps someone find this quicker than I did.
    – amenthes
    Jan 3 at 18:37
1
  • You need only to install Pygments into Python, Pygmentize is a command available once Pygments have been installed.

    You can check it has been properly installed on Windows and can be accessed in the PATH by typing in a command line:

    pygmentize -h

    Which will print the help message.

  • Don't forget to use the -shell-escape option in order to allow your tex compiler to access the external commands.

    See how to do it here

  • Make sure you have all your MiKTeX packages up to date. In my case, my antivirus software was preventing some MiKTeX packages updates, which in turn where making minted unusable.

    I fount this solution here

  • As @darthbith suggested in the comments, closing and reopening (or a system restart) can be needed for the PATH to be reloaded.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.