How can I install packages in Mathematica Online?
In particular, how can I install the xAct package?
How can I install packages in Mathematica Online?
In particular, how can I install the xAct package?
In general, packages need to be placed in the Applications
directory within $UserBaseDirectory
. $UserBaseDirectory
has different locations on different systems. With standard Mathematica, we can just evaluate $UserBaseDirectory
to find this location, e.g. on a Windows system:
$UserBaseDirectory
(* "C:\\Users\\JoeUser\\AppData\\Roaming\\Mathematica" *)
Also, SystemOpen[$UserBaseDirectory]
will open it in the system's file manager.
Note: not all packages follow the standard so be sure to read the package's documentation for package-specific installation instructions.
What about the cloud? (Note: I do not have access to Mathematica Online so I am going to work with the Programming Cloud, hoping that they're similar enough.) The value of $UserBaseDirectory
has less information about how to actually put files there, but we can navigate to Home > Base using the cloud's file manager:
Navigate to Applications and place the package there.
A package may be a single .m
or .wl
file, in which case doing this is simple, or it may come as a directory, which makes uploading more difficult. I have not found a way to upload a directory (please let me know if there's a way!), so I took the following approach instead: upload an archive and extract it using ExtractArchive
. Or we can download the file directly to the cloud using URLSave
. Using xAct as an example,
SetDirectory@FileNameJoin[{$UserBaseDirectory,"Applications"}]
URLSave["http://www.xact.es/download/xAct_1.1.1.tgz","xAct.tgz"]
ExtractArchive["xAct.tgz"];
DeleteFile["xAct.tgz"]
Now we have the xAct
directory within Base/Applications
, the package is installed.
How to install xAct specifically? xAct follows the standard installation procedure, so the above steps work. But unfortunately it is not compatible with Mathematica Online because it relies on separate executables, which are not supported in the cloud due to security reasons.
In short, this package won't work because it's written in a mix of Mathematica and C. Most packages written in pure Mathematica should work.
$UserBaseDirectory/Applications
. Use the file browser of Mathematica Online and navigate toBase/Applications
. Place the package there, as described in the installation instructions. I have not tested this (also I don't have Mathematica Online, only the free version of the Programming Cloud). $\endgroup$<<xAct`
but<<xAct`subPackage`
for each possible subpackage. The OP seems to not have read the introductory documentation. $\endgroup$<<xAct`xTensor`
, it tries to load xPerm as well, which relies on an external executable. This is not supported in the programming cloud (and I'd assume the same for Mathematica Online too). For this reason, xAct seems not to be compatible with Mathematica Online. $\endgroup$