6

I'd like to do similar as to what I can with Python - pip freeze > installed.txt and pip install -r installed.txt.

Is this possible?

Geesh_SO
  • 211
  • 2
  • 5
  • Welcome to TeX.SX! Interesting question. – egreg Feb 26 '18 at 18:13
  • Good question. An alternative solution is to use the portable version of MikTeX (or TeXLive) instead. Then once you get it working, make a zip archive of the whole thing. Unzip it wherever desired. Also great for making a backup installation, in case your current installation is somehow disturbed. –  Feb 27 '18 at 15:38
  • Funny that you'd make that comment. I do use MikTeX portable however (through a fault of my own) I had managed to corrupt it but I was still able to interface with MPM, hence why I was trying to save the package list. Your suggestion is definitely a good one in general! – Geesh_SO Feb 27 '18 at 15:55

2 Answers2

5

In lieu of someone more in the know, I believe that I worked it out (although it turned out I didn't need it in the end).

I first used mpm to get a list of my installed packages (I used grep through Git Bash on my Windows machine).

mpm --list | grep ^i > installed.txt

However this contains more information than just names.

i 00003       1494 zerohyph

So I used Notepad++ to do a regex replace to find the stuff prior to the name and replace it with nothing.

^.*\d+ 

With a file which listed package names, I then ran the command to install the packages.

mpm --require=@installed.txt

Which seemed to work okay.

28 packages have been successfully installed.

I'm sure that this could be improved upon.

Geesh_SO
  • 211
  • 2
  • 5
  • 1
    You could get rid of the Notepad++ step by using awk to grab the fourth column. This is included w/ Git Bash on Windows.

    mpm --list | grep ^i | awk '{print $4}' > mpmlist.txt.

    – matthew-e-brown Apr 09 '20 at 07:42
  • Also, just in case, it might be worth running Git Bash as Administrator and using mpm --admin --list to start with. – matthew-e-brown Apr 09 '20 at 07:58
  • Unfortunately --list is deprecated. https://docs.miktex.org/manual/mpm.html – Morty Sep 22 '22 at 09:01
  • This does not seem to handle the package version. It will only install the latest version of every package – Arthur Attout Aug 17 '23 at 08:56
2

I use a different method when I upgrade Miktex as described here. This can also be used to transfer an installation.

user41974
  • 841