Minted cannot find pygmentize in TexStudio on Windows 7

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?


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!


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