MiKTeX and Perl scripts (and one Python script)

50,246

A definitive solution could only be given by Christian Schenk, the developer of MiKTeX. I am like most others just a simple user without knowledge in reading the MiKTEX sources. But nevertheless from empiric experience I guess he removed intentionally the rudimentary Perl included in earlier versions (as already said in question: my memory can deceive me), so it’s one thing less, he has to keep up to date. In this case the real issue would be, that this seems nowhere to be mentioned in official MiKTeX documents or on MiKTeX.org (again: mistakes on my side are possible).

So, what can be done then?

I will only describe the approach for Perl, but for Python it is analogical. Download overview in Python for Windows.

The answer is: Install a full Perl distribution on your own!

You can find links to Windows versions of Perl distributions on Perl.org download page.

If you have no idea, which one to choose, I suggest you to install ActivePerl by ActiveState. There’s a “Free Community Edition” installer (at time of writing do not download the latest version, but the recommended one, because otherwise you cannot add perl repositories for module updating). By default a package manager is also installed which is later useful for updates and configuration.
For advanced users there’s also Strawberry Perl for Windows. The configuration is later done with command prompt terminals.
Both installers add the Perl interpreter to the system PATH environment variable and link the file extension .pl to the interpreter binary perl.exe, so it would generally be enough to start with click on the file or in command prompt typing in the file alone - but this does not work for files without extension (but perl file would work then).*)
I cannot say anything about the third mentioned distribution DWIM Perl for Windows, but since it is claimed to be Strawberry based, it will be very similar.

*) (One could even go further and add the file extension to system variable PATHEXT, see How do I make my Perl scripts act like normal programs on Windows?) for more.

But what to do, when Perl is installed, and even though still errors appear?

Sometimes the error is caused by another issue. Back in past almost every time the reason was, that a script path had changed, but the developer had forgotten to adjust the entry in scripts.ini. You cannot edit the file, as this would break functioning at all! (The file is signed.) But in such a case you can do the following. I’ll take latexdiff as example, where this once really happened.

  1. Make sure you have created a local root directory, cf. Create a local texmf tree in MiKTeX. We will only need the bin subfolder here for what we want. You could also use another folder. That is in the system path, though, but mind the point, that it must be found before the MiKTeX binaries folder.

  2. Start your favorite text editor and paste in the following lines. Of course, adjust the path to your installation, for the exact script path and name you have to look yourself:

    @echo off & setlocal
    
    :: Adjust path to MiKTeX root here, do not remove
    :: the double quotes, when you have spaces in path!
    :: By default in a 32-bit machine:
    :: set MiKTeXPath="C:\Program Files\MiKTeX 2.9"
    set MiKTeXPath="<Path-to-MiKTeX>"
    
    perl %MiKTeXPath%\scripts\latexdiff\latexdiff %*
    

    The last line would be different for texdef:

    perl %MiKTeXPath%\scripts\texdef\perl\texdef.pl %*
    

    You could remove the lines with double-colons in the beginning.

  3. Save as text file in the binaries folder mentioned in item 1 above with the name as it appears before the equal sign in scripts.ini and the file extension .bat (or .cmd if you like this more), so in the example latexdiff.bat. Windows’ own Notepad is notorious for adding the extension .txt automatically. You can avoid this, when you save the file with double quotes: "latexdiff.bat".

  4. Do a test: open the command prompt and type in latexdiff --version or latexdiff --help. When you get no output from your Perl script, then you must check whether you have typed the correct script path and name, and the binary folder with the batch file is found before the MiKTeX bin folder. The file extension is omitted, because the real calls are also made without it.

  5. From time to time you should test, whether the function in MiKTeX was repaired. You can do this with typing explicitly the .exe wrapper version: latexdiff.exe --version. If successful you can delete the batch file then.

Share:
50,246

Related videos on Youtube

Speravir
Author by

Speravir

Updated on August 29, 2020

Comments

  • Speravir
    Speravir about 3 years

    Again and again here on TeX.SX users of MiKTeX ask a question having a problem with a package or included program, where it turns out, that a Perl script is involved, in particular glossaries (because of the script makeglossaries), latexdiff and latexmk. In most cases the error message looks like this:

    makeglossaries.exe: The Perl interpreter could not be found.

    When my remembrance does not deceive me, it must have worked in earlier versions of MiKTeX out of the box.

    Though there are answers to questions serving more than the special issue, can we give here a basic solution even if it is not TeX related?

    Let me list which Perl scripts are included in MiKTeX at time of writing (excerpt from MiKTeX configuration file scripts.ini), for every script line exists a executable in the binaries subfolder with the name seen before the equal sign:

    OOopict=scripts/gapfill/OOopict.pl
    afm2afm=scripts/fontools/perl/afm2afm.pl
    arlatex=scripts/bundledoc/arlatex
    authorindex=scripts/perl/authorindex/authorindex.pl
    autoinst=scripts/fontools/perl/autoinst.pl
    bib2xhtml=scripts/bib2xhtml/perl/bib2xhtml.pl
    bibhtml=scripts/bibhtml/perl/bibhtml.pl
    biokey2html1=scripts/shipunov/biokey2html1.pl
    biokey2html2=scripts/shipunov/biokey2html2.pl
    biokey2html3=scripts/shipunov/biokey2html3.pl
    birm=scripts/burmese/perl/birm.pl
    bundledoc=scripts/bundledoc/bundledoc
    cmap2enc=scripts/fontools/perl/cmap2enc.pl
    csvtools=scripts/csvtools/perl/csvtools.pl
    ctanify=scripts/ctanify/ctanify
    ctanupload=scripts/ctanupload/ctanupload.pl
    dosepsbin=scripts/dosepsbin/dosepsbin.pl
    etexdef=scripts/texdef/perl/texdef.pl
    exceltex=scripts/exceltex/perl/exceltex
    feynmf=scripts/feynmf/perl/feynmf.pl
    fig4latex=scripts/fig4latex/perl/fig4latex.pl
    findhyph=scripts/findhyph/perl/findhyph.pl
    font2afm=scripts/fontools/perl/font2afm.pl
    fullref=scripts/aomart/perl/fullref.pl
    htcopy=scripts/tex4ht/htcopy.pl
    htmove=scripts/tex4ht/htmove.pl
    ibyhyph=scripts/perl/ibycus-babel/ibyhyph.pl
    latex-git-log=scripts/latex-git-log
    latexdef=scripts/texdef/perl/texdef.pl
    latexdiff-fast=scripts/latexdiff/latexdiff-fast
    latexdiff-so=scripts/latexdiff/latexdiff-so
    latexdiff-vc=scripts/latexdiff/latexdiff-vc
    latexdiff=scripts/latexdiff/latexdiff
    latexindent=scripts/latexindent/latexindent.pl
    latexmk=scripts/latexmk/perl/latexmk.pl
    latexpand=scripts/latexpand/latexpand
    latexrevise=scripts/latexdiff/latexrevise
    ltximg=scripts/ltximg/ltximg.pl
    lualatexdef=scripts/texdef/perl/texdef.pl
    luatexdef=scripts/texdef/perl/texdef.pl
    makeglossaries=scripts/glossaries/makeglossaries
    makejmlrbook=scripts/jmlr/makejmlrbook
    mathspic113=scripts/mathspic/mathspic113.pl
    mathspic=scripts/mathspic/mathspic113.pl
    mf2pt1=scripts/mf2pt1/mf2pt1.pl
    mk4ht=scripts/tex4ht/mk4ht.pl
    mkjobtexmf=scripts/mkjobtexmf/mkjobtexmf.pl
    mkt1font=scripts/perl/accfonts/mkt1font.pl
    mptopdf=scripts/context/perl/mptopdf.pl
    orderrefs=scripts/perl/orderrefs/orderrefs.pl
    ot2kpx=scripts/fontools/perl/ot2kpx.pl
    pdfatfi=scripts/oberdiek/pdfatfi.pl
    pdfcrop=scripts/pdfcrop/pdfcrop.pl
    pdflatexdef=scripts/texdef/perl/texdef.pl
    pdftexdef=scripts/texdef/perl/texdef.pl
    pedigree=scripts/pedigree-perl/pedigree-perl/perl/pedigree.pl
    perltex=scripts/perltex/perl/perltex.pl
    pfm2kpx=scripts/fontools/perl/pfm2kpx.pl
    pkfix-helper=scripts/pkfix-helper/pkfix-helper
    pkfix=scripts/pkfix/pkfix.pl
    pn2pdf=scripts/perl/petri-nets/pn2pdf.pl
    pst2pdf=scripts/pst2pdf/perl/pst2pdf.pl
    rcsinfo=scripts/rcsinfo/perl/rcsinfo.pl
    showglyphs=scripts/fontools/perl/showglyphs.pl
    splitindex=scripts/splitindex/perl/splitindex.pl
    sty2dtx=scripts/sty2dtx/perl/sty2dtx.pl
    svn-multi=scripts/svn-multi/svn-multi.pl
    texcount=scripts/texcount/perl/texcount.pl
    texdef=scripts/texdef/perl/texdef.pl
    texdiff=scripts/texdiff/perl/texdiff.pl
    texdirflatten=scripts/texdirflatten/perl/texdirflatten.pl
    thumbpdf=scripts/thumbpdf/perl/thumbpdf.pl
    urlbst=scripts/urlbst/urlbst
    vpe=scripts/vpe/vpe.pl
    vpl2ovp=scripts/perl/accfonts/vpl2ovp.pl
    vpl2vpl=scripts/perl/accfonts/vpl2vpl.pl
    xdv2pdf_mergemarks=scripts/xetex/perl/xdv2pdf_mergemarks.pl
    xelatexdef=scripts/texdef/perl/texdef.pl
    xetexdef=scripts/texdef/perl/texdef.pl
    

    There is very probably a similar issue for the one listed Python script:

    pgfplots=scripts/pgfplots/pgfplots.py
    

    PS: Lua scripts are not affected!

  • texenthusiast
    texenthusiast almost 10 years
    I thought after installing active perl or python we should be done. Why does one need steps 1 to 5, looks complex to me, may be the miktex author can do something if posted as request.
  • Speravir
    Speravir almost 10 years
    @texenthusiast: "Sometimes the error is caused by another issue …" etc.?
  • Igor Kotelnikov
    Igor Kotelnikov over 7 years
    I have installed ActivePerl but xindy still says C:\Program Files\Far Manager>xindy.exe --help xindy.exe: The script interpreter could not be found. xindy.exe: Data: scriptInterpreter="perl.exe"