Mathematica Installation
Mathematica Installation
https://help.ubuntu.com/community/Mathematica
Mathematica
Style Cleanup Required: This article does not follow the style standards in the Wiki Guide. More info... Mathematica is not free software, see ['UbuntuScience'] for alternatives.
Contents 1. Installation 1. Autoloading Packages 2. Known Issues and Workarounds 1. Environment Variables 2. Applet Bug 3. Sound 4. SMP Machines 5. [: 215: ==: unexpected operator 6. X.org Composite Extension 7. Numlock / Alt / Ctrl / Backspace Problems 8. Locale Errors 9. AMD 64 Users on Ubuntu 5.10 3. External Links 4. Comments 1. Wine
Installation
Mathematica has an installer named MathInstaller. It is in
/cdrom/Unix/Installers/Linux
MathInstaller will not run from the CD since, by default, ubuntu mounts CDs with the noexec option. To solve this simply run the installer with the sh command
sudo sh MathInstaller
Alternatively you can copy the Linux installer to a temporary directory and run MathInstaller:
mkdir -p /tmp/Mathematica/Installers cp -r /cdrom/Unix/Installers/Linux /tmp/Mathematica/Installers cd /tmp/Mathematica/Installers/Linux/ ./MathInstaller
After that, the script asks a series of questions, including the licensing information. It ends installing Mathematica in /usr/local, and it creates a symbolic link /usr/bin/mathematica. You may need to restart gnome to get the fonts working properly.
Autoloading Packages
Mathematica has a certain core set of functionality that is automatically available. There are also a number of "packages" that can be manually loaded to get additional functions. Examples include the Graphics and LinearAlgebra packages. If, like me, you think that these should always be available, it is easy to make it so. Simply run the commands below:
cd /usr/local/Wolfram/5.1/AddOns/StandardPackages for i in `find -name init.m | sed s/..//` ; do mkdir -p ~/.Mathematica/Autoload/`dirname $i` ; cp $i ~/.Mathematica/Autoload/`dirname $i` ; done
This will make it so you no longer have to run <<`PackageName` to load a package; it will load as soon as you use a function from the package. The above command enables autoloading for you. Change ~/.Mathematica/AutoLoad to /usr/local/Wolfram/5.1/AddOns/AutoLoad to enable autoloading for all users. Remember to change the version number if you don't have version 5.1.
1 of 6
07-07-2011 04:22
https://help.ubuntu.com/community/Mathematica
A number of fixes involve setting environment variables. There are several ways to set these and have them be seen by Mathematica (or other programs). First, you can add them to your ~/.bashrc:
export VARIABLE=value
This will make the variable visible to all programs you run from the command line. You can also set the variable when launching the program:
VARIABLE=value Mathematica
Applet Bug
On 5.10+ there is a bug with Mathematica and the window-list and workspace-switcher applets. After starting Mathematica the applets take up 100% of CPU. If you start mathematica with no splash screen
mathematica -noSplashScreen
everything seems to work fine You can use it for creating an Ubuntu launcher.
Sound
Mathematica sound doesn't work in Linux, and Wolfram Research probably isn't going to integrate it anytime soon. Here is a workaround that should work well. It assumes that you have aRts installed and running. To install aRts,
sudo apt-get install arts
To start aRts,
artswrapper -s 2 &
Now, create the file ~/.Mathematica/Kernel/sound.m and copy the following Mathematica program into it.
(* * Set up a $SoundDisplayFunction for the * Linux version of Mathematica and potentially other unixes, too. *) Begin["System`Private`"] Unprotect[$SoundDisplayFunction] Clear[$SoundDisplayFunction] $SoundDisplayFunction = Module[{playCmd,soundFileName}, Display[$SoundDisplay, #1]; (* is there a way to get the sample rate, etc. from the audio stream? *) playCmd = "artsplay"; soundFileName = "/dev/shm/" <> ToString[Unique["sound"]] <> ".wav"; playCmd = playCmd <> " " <> soundFileName; Export[soundFileName, #1, "WAV"]; Run[playCmd]; Run["/bin/rm -f " <> soundFileName]; ] &
2 of 6
07-07-2011 04:22
https://help.ubuntu.com/community/Mathematica
Protect[$SoundDisplayFunction] End[];
Try using Play[] to see if it worked. The command to start aRts could be placed in init.m (personally, I start it in ~/.xsession). If you put it in init.m, then you'll probably want to suppress any error messages like this
artswrapper -s 2 >& /dev/null &
If you don't like aRts, by all means use a different command to play the sounds. The sound.m file is pretty easy to follow. sound.m uses /dev/shm as a temporary directory. This means that it's fast, but also can't handle huge sound files. Change /dev/shm to, say, /tmp or ~/tmp if you're concerned.
SMP Machines
There is a bug in Mathematica 5.1 (possibly others) where certain functions take a long time or hang the Mathematica Kernel on SMP machines. An example function is LinearSolve[]. You have an SMP machine if /proc/cpuinfo lists more than one processor. The work around is to set an environment variable before launching Mathematica:
export LD_ASSUME_KERNEL=2.4.1
This tells the runtime linker (ld) to use the threading and other support libraries expected by Mathematica. On some systems,
export OMP_NUM_THREADS=1
This is because the sh scripts uses bash syntax, and sh is not emulated by bash any more. You can fix this by editing the first line of the "math" and "MathKernel" scripts in Mathematica5.2/Executables from
#!/bin/sh
to
#!/bin/bash
3 of 6
07-07-2011 04:22
https://help.ubuntu.com/community/Mathematica
If this doesn't work, you can just be careful about dragging the scroll bar, and the problem will be minimized. You can use arrow keys, page up/down, click (not drag) in the scrollbar, or use scrollbar buttons.
or
xrdb -merge ~/.Xresources
You can add the above line to a script that is run at login (e.g., ~/.xsession or ~/.xinitrc) to set them every time you login. You can see all of the Xresources Mathematica recognizes (and their defaults) in the file mentioned above. The other thing to look at is xmodmap, which is used to (re)define keymappings. The following works for me in conjunction with the above Xresources (these were done a long time ago, and I'm pretty sure that these don't address Mathematica problems).
xmodmap xmodmap xmodmap xmodmap xmodmap -e -e -e -e -e "keycode 115 = Super_L" "keycode 116 = Super_R" "keycode 117 = Menu" "add mod4 = Super_L Super_R" "remove lock = Caps_Lock"
Locale Errors
The bug manifests itself with: error complaining about the locale settings lots of lines repeating various blends of "Warning: translation table syntax error" window list applet got stuck when the splash screen appeared segmentation fault & Mathematica death A workaround is:
cd /usr/X11R6/lib/X11/ sudo mv locale locale.bck sudo ln -s /usr/share/X11/XKeysymDB XKeysymDB sudo ln -s /usr/share/X11/locale/ locale
4 of 6
07-07-2011 04:22
https://help.ubuntu.com/community/Mathematica
This can be remedied with this procedure: First, add the following lines to the "math" script using your favorite editor:
x86_64) SystemIDList="Linux";;
Next, run "math" and enter all of your registration and licensing information. This step is important even though it may not seem to be at the time of doing this. I could not seem to get the Reg splash screen to run for me, and Mathematica would crash out with a Segmentation Fault. Finally, make the same exact addition to the "mathematica" script. Now you should be able to run the "mathematica" script and have the GUI start up properly.
External Links
http://support.wolfram.com/
Comments
Wine
Installing Mathematica with Wine 0.9.31 works, although a bit unstable. For instance, the beep generated by warning/error messages causes it to crash. A quick fix is to disable them (Preferences > Global Options > MessageOptions)
5 of 6
07-07-2011 04:22
https://help.ubuntu.com/community/Mathematica
Page History
6 of 6
07-07-2011 04:22