What is the proper procedure way to install new packages for Mathematica?
In particular, when you download any notebook from MathWorld, you are are given a link to Mathworld packages, which is are zip files with dozens of .m files
Where do they go?
To have your packages that you've either downloaded or personally created visible to Mathematica, put them in $UserBaseDirectory/Applications
, or $BaseDirectory/Applications
if you want them accessible to all users on your system. Alternatively, version 8.0.4 (and likely earlier) has a menu option: File -> Install which will do it for you. The menu option brings up the following dialog
where the option "Install for this user only (name)" would install it under $UserBaseDirectory
and the "for all users" option would install it under $BaseDirectory
.
For more information on where Mathematica places everything I would read this tutorial, and look through directory operations functionality.
If they are just temporary packages, it is often easier to load them from the current directory, but otherwise moving the files to anywhere on $Path
(such as $UserBaseDirectory/Applications
as suggested by rcollyer) will work although some directories are autoloaded.
My usual solution is to have
SetDirectory[NotebookDirectory[]]
as more or less the first line in all notebooks. I can then load packages from the notebook directory with Needs["foo
"]`. For versioning, you can use the more verbose form of needs:
Needs["foo`","foo-001.m"]
Under Windows it is often better to use %AllUsersProfile%
directory instead of %UserProfile%
for storing additional packages. The following command gives the path to the corresponding directory under Windows:
First@ReadList["!cmd /C echo %AllUsersProfile%",
String] <> "\\Application Data\\Mathematica\\Applications"
P.S. I think this and this answers of John Fultz are relevant.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With