1

[This is a follow-up question to this question.]

I am trying to use the minted package in MikTex to format the Python script. I am getting the error

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

I assume it means 'pygments', as I can find nothing on 'pygmentize'.

However, pygments is installed and I put the folder the distribution is in on the PATH. I note that there are only Python files in this folder (no exe files), so perhaps I should be putting something different on the PATH?

The path I am using is

C:\ProgramData\Anaconda3\Lib\site-packages\pygments

which has a directory listing

 Directory of C:\ProgramData\Anaconda3\Lib\site-packages\pygments

24/06/2021 20:26 <DIR> . 24/06/2021 20:26 <DIR> .. 07/03/2021 19:56 21,538 cmdline.py 07/03/2021 19:56 1,697 console.py 07/03/2021 19:56 1,938 filter.py 24/06/2021 20:26 <DIR> filters 07/03/2021 19:56 2,893 formatter.py 24/06/2021 20:26 <DIR> formatters 07/03/2021 19:56 31,477 lexer.py 24/06/2021 20:26 <DIR> lexers 07/03/2021 19:56 986 modeline.py 07/03/2021 19:56 1,710 plugin.py 07/03/2021 19:56 3,070 regexopt.py 07/03/2021 19:56 3,091 scanner.py 07/03/2021 19:56 4,594 sphinxext.py 07/03/2021 19:56 6,011 style.py 24/06/2021 20:26 <DIR> styles 07/03/2021 19:56 6,143 token.py 07/03/2021 19:56 63,200 unistring.py 07/03/2021 19:56 9,123 util.py 07/03/2021 19:56 3,012 init.py 07/03/2021 19:56 348 main.py 24/06/2021 20:26 <DIR> pycache

Is this the right directory? If so, how do I get MikTex to pick up on this?

Update

Based on the comments I got on this question, I was able to make some progress. I was able to find pygmentize.exe in the directory

C:\ProgramData\Anaconda3\Scripts

After adding this to the path, I re-ran MikTex, getting over the

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

error. Unfortunately, this just opened a new can of worms and I ended up with several Access denied errors.

I could continue to pursue this. However, inspired by the comments I got, I opened up the MikTex console (initially looking for the pygmentex package, as suggested below). I didn't find this, but I did find

pythonhighlight

This ran first time with no problems, rendering my Python code appropriately (which was the object of the whole exercise). So my advice to anyone else having trouble getting minted to work is "don't bother" - use pythonhighlight instead!

1 Answers1

0

You must add TWO folders to your PATH: the one where your executable python is and the one with pygmentize.exe.

In my case I have a portable installation of WinPython in this folder:

d:\Roberto\WPy64-31090

So I added these two folders to the existing PATH:

set PATH=%PATH%;d:\Roberto\WPy64-31090\python-3.10.9.amd64\;d:\Roberto\WPy64-31090\python-3.10.9.amd64\Scripts\;

Windows 10 has got a system wide alias for "python" and "python3" that invites you to install Python from the Windows Store. This prevented MikTex from calling the Python executable in the path. I had to search in the control panel and deactivate it. You should be able to access it under Settings - Apps - Apps and features - Manage app execution aliases. Find "python" and "python3" and deactivate them.