This is always a problem when I distribute my packages to colleagues working on different platforms. I have my packages installed into a private directory and I autoload some of them when Mathematica starts, but since everyone has a different folder hierarchy and different customs on where to put files/what to autoload, this is always a bottleneck. Should non-power-users simply use the menu option: Install...? Can a foolproof script be defined, that - no matter what platform is in use - installs these packages in a way that both the user and both Mathematica (and the code I wrote and distributed) can find it? That is, packages are not added to the system-default package directory. Or would it be better to put packages into the default directory of Mathematica (e.g. C:\Applications\Mathematica 8.0.1\AddOns)? If yes, then which directory should hold them: LegacyPackages, ExtraPackages or Packages?

Further questions:

What if the package that I send consists of multiple packages, in a delicate directory structure? Can the menuitem Install... deal with that?

  • $\begingroup$ I never looked at the install option before, I've always done it by hand. $\endgroup$
    – rcollyer
    Commented Jan 25, 2012 at 17:51

3 Answers 3


Note: This answer was originally written with package authors in mind, aiming to provide a user-friendly way to distribute packages and provide installation instructions. If your aim is user convenience, today you should be using paclets instead.

I think that the menu item File -> Install... is very convenient, even for power users. The only problem is that there is no uninstall option. However, if the package consists of a single file, upgrading is easy: the old file will be overwritten with the new file.

You can write some simple instructions for users:

  1. Open the .m file you sent them
  2. Choose File -> Install...
  3. Choose Type -> Package, Source -> (the open notebook), Install Name -> SomePackage
  4. Load the package by evaluating <<SomePackage` .

The only thing that can go wrong is that they mistype the install name.

The Install... menu item will put the package into

FileNameJoin[{$UserBaseDirectory, "Applications"}]

which on Windows is


(Press Win-R and type the above to get to that directory.)

When necessary, the package file can be deleted from that directory.

This is the usual way I install and upgrade palettes myself.

Putting packages into the Mathematica installation directory is not really advantageous because they will get lost when Mathematica is upgraded (for example, from 8.0.1 to 8.0.4). Instead they can be put into $BaseDirectory/Application (for all users) or $UserBaseDirectory/Application (for the current user). This is what the Install... menu item does.

It seems that the Install... menu item can deal with multi-file packages too. "Type of Item to Install" should be set to "Applications", "Source" -> "From File..." and the package files need to be inside an archive (.zip file). I have not used this personally, so I have no experience with it (e.g. about what happens on upgrade).

@AlbertRetey noted below that the Wolfram Player Pro does not have this menu item at all. The only way to install packages into it is to do it manually or create a script that does it.

  • $\begingroup$ See edit in original post about multifile packages. Thanks for clearing up what exactly the Install... does. It was sort of a black box up till now. $\endgroup$ Commented Jan 25, 2012 at 18:34
  • $\begingroup$ @István Edited, seems possible, but I have no experience with this ... $\endgroup$
    – Szabolcs
    Commented Jan 25, 2012 at 18:37
  • 1
    $\begingroup$ @István Thinking about it, for packages it really doesn't make a big difference. For palettes, using Install... is pretty convenient because palettes are commonly generated (they don't come from a file). $\endgroup$
    – Szabolcs
    Commented Jan 25, 2012 at 19:03
  • 2
    $\begingroup$ There is another thing that might or might not be a problem: the PlayerPro is missing the File -> Install menu. You will need to write a script that installs as Leonid has suggested if you want to deploy to PlayerPro. $\endgroup$ Commented Jan 25, 2012 at 21:01
  • $\begingroup$ @Albert Good point, I was not aware of that $\endgroup$
    – Szabolcs
    Commented Jan 25, 2012 at 21:27

One very simple option: install all packages into

FileNameJoin[{$UserBaseDirectory, "Applications"}]

It is trivial to write a script which will do that, and this is a platform-independent way of specifying a directory which always exists, and where Mathematica will always look for packages.

As an alternative, you can give the user a choice of a directory, and append it to the $Path variable.

I would not recommend putting packages into system folders such as AddOns, for many reasons. One is that there can be many users on the machine with a single installation of Mathematica, and if you put it into a system folder, all of them will experience its presence there, whether they want it or not (and whether you want it or not).

  • $\begingroup$ +1 everything user should be in $UserBaseDirectory for easy management. Copy system files to this directory as needed, duplicating the tree, if you need to modify them. $\endgroup$
    – Mr.Wizard
    Commented Jan 25, 2012 at 17:56
  • 2
    $\begingroup$ Also, packages in the system folder will get lost on upgrade (from e.g. 8.0.1 to 8.0.4) $\endgroup$
    – Szabolcs
    Commented Jan 25, 2012 at 17:58
  • 1
    $\begingroup$ To all: I can tell you that anything in the $UserBaseDirectory (if left as default) can get lost when reinstalling Windows. Therefore, I have a very strong feeling against putting my stuff into whatever directory the OS offers. $\endgroup$ Commented Jan 25, 2012 at 18:31
  • 3
    $\begingroup$ @Istvan Well, a lot can get lost when reinstalling Windows. $\endgroup$ Commented Jan 25, 2012 at 18:36
  • 1
    $\begingroup$ @Leonid: Nothing gets lost if kept at a safe place out of the installer's path, preferably on an other drive :) $\endgroup$ Commented Jan 25, 2012 at 18:47

If you found this question while looking for user-friendly ways to distribute your own package, you should look into using paclets:

Using paclets is the future:

  • Packages come as a single .paclet file.
  • They can be installed with the convenient PacletInstall command, and uninstalled with PacletUninstall.
  • Paclets can contain metadata about which Mathematica versions and which platforms they are compatible with, eliminating the problem where people inadvertently try to use a package on an incompatible system.

There is currently absolutely no reason not to use the paclet format for distributing any Mathematica package. Compatibility is not a concern. While the paclet system became documented only in Mathematica 12.1, most of its features work in Mathematica 10.0, or even earlier versions.

  • $\begingroup$ Thanks Szabolcs for the update. Do you think I should accept this answer (being the most relevant in modern times) or should I leave it as is, for those still looking explicitly for package installation? $\endgroup$ Commented Jun 29, 2021 at 12:38
  • $\begingroup$ @IstvánZachar This QA is useful both for package developer and package users. This answer is aimed mostly at package developers, and the accepted answer already has a link here. I think it's fine if we keep things as they are, but in the end it's up to you. $\endgroup$
    – Szabolcs
    Commented Jun 29, 2021 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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