“UbuntuHelp:Mathematica”的版本间的差异
来自Ubuntu中文
小 |
小 |
||
(未显示同一用户的7个中间版本) | |||
第1行: | 第1行: | ||
{{From|https://help.ubuntu.com/community/Mathematica}} | {{From|https://help.ubuntu.com/community/Mathematica}} | ||
{{Languages|UbuntuHelp:Mathematica}} | {{Languages|UbuntuHelp:Mathematica}} | ||
− | + | <<Include(Tag/StyleCleanup)>> | |
− | + | ||
Mathematica is not free software, see ['UbuntuScience'] for alternatives. | Mathematica is not free software, see ['UbuntuScience'] for alternatives. | ||
− | |||
== Installation == | == Installation == | ||
− | |||
Mathematica has an installer named Math''''''Installer. It is in | Mathematica has an installer named Math''''''Installer. It is in | ||
<pre><nowiki> | <pre><nowiki> | ||
第15行: | 第12行: | ||
sudo sh MathInstaller | sudo sh MathInstaller | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
Alternatively you can copy the Linux installer to a temporary directory and run Math''''''Installer: | Alternatively you can copy the Linux installer to a temporary directory and run Math''''''Installer: | ||
<pre><nowiki> | <pre><nowiki> | ||
− | mkdir /tmp/Mathematica/Installers | + | mkdir -p /tmp/Mathematica/Installers |
− | + | cp -r /cdrom/Unix/Installers/Linux /tmp/Mathematica/Installers | |
− | + | ||
cd /tmp/Mathematica/Installers/Linux/ | cd /tmp/Mathematica/Installers/Linux/ | ||
./MathInstaller | ./MathInstaller | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
After that, the script asks a series of questions, including the licensing information. | 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. | 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. | You may need to restart gnome to get the fonts working properly. | ||
− | |||
=== Autoloading Packages === | === 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 <code><nowiki>Graphics</nowiki></code> and <code><nowiki>LinearAlgebra</nowiki></code> packages. If, like me, you think that these should always be available, it is easy to make it so. Simply run the commands below: | 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 <code><nowiki>Graphics</nowiki></code> and <code><nowiki>LinearAlgebra</nowiki></code> packages. If, like me, you think that these should always be available, it is easy to make it so. Simply run the commands below: | ||
− | |||
<pre><nowiki> | <pre><nowiki> | ||
cd /usr/local/Wolfram/5.1/AddOns/StandardPackages | 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 | for i in `find -name init.m | sed s/..//` ; do mkdir -p ~/.Mathematica/Autoload/`dirname $i` ; cp $i ~/.Mathematica/Autoload/`dirname $i` ; done | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
This will make it so you no longer have to run <code><nowiki><<`PackageName`</nowiki></code> 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 <code><nowiki>~/.Mathematica/AutoLoad</nowiki></code> to <code><nowiki>/usr/local/Wolfram/5.1/AddOns/AutoLoad</nowiki></code> to enable autoloading for all users. Remember to change the version number if you don't have version 5.1. | This will make it so you no longer have to run <code><nowiki><<`PackageName`</nowiki></code> 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 <code><nowiki>~/.Mathematica/AutoLoad</nowiki></code> to <code><nowiki>/usr/local/Wolfram/5.1/AddOns/AutoLoad</nowiki></code> to enable autoloading for all users. Remember to change the version number if you don't have version 5.1. | ||
− | |||
== Known Issues and Workarounds == | == Known Issues and Workarounds == | ||
− | |||
=== Environment Variables === | === Environment Variables === | ||
− | + | 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 <code><nowiki>~/.bashrc</nowiki></code>: | |
− | A number of | + | |
<pre><nowiki> | <pre><nowiki> | ||
− | export VARIABLE=value | + | export VARIABLE=value |
</nowiki></pre> | </nowiki></pre> | ||
− | This will make the variable visible to | + | 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: |
<pre><nowiki> | <pre><nowiki> | ||
− | + | VARIABLE=value Mathematica | |
</nowiki></pre> | </nowiki></pre> | ||
− | + | Or you can make a launcher script like this: | |
<pre><nowiki> | <pre><nowiki> | ||
− | #!/bin/ | + | #!/bin/sh |
− | + | VARIABLE1=value1 VARIABLE2=value2 Mathematica -option1 -option2 | |
− | + | ||
− | Mathematica -option1 -option2 | + | |
</nowiki></pre> | </nowiki></pre> | ||
− | |||
=== Applet Bug === | === 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. | 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 | If you start mathematica with no splash screen | ||
<pre><nowiki> | <pre><nowiki> | ||
第70行: | 第51行: | ||
</nowiki></pre> | </nowiki></pre> | ||
everything seems to work fine | everything seems to work fine | ||
− | |||
You can use it for creating an Ubuntu launcher. | You can use it for creating an Ubuntu launcher. | ||
− | |||
=== Sound === | === 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, | 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, | ||
第82行: | 第61行: | ||
artswrapper -s 2 & | artswrapper -s 2 & | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
Now, create the file <code><nowiki>~/.Mathematica/Kernel/sound.m</nowiki></code> and copy the following Mathematica program into it. | Now, create the file <code><nowiki>~/.Mathematica/Kernel/sound.m</nowiki></code> and copy the following Mathematica program into it. | ||
<pre><nowiki> | <pre><nowiki> | ||
(* | (* | ||
− | * Set up a $SoundDisplayFunction for the | + | * Set up a $SoundDisplayFunction for the |
− | * Linux version of Mathematica and potentially other unixes, too. | + | * Linux version of Mathematica and potentially other unixes, too. |
− | *) | + | *) |
− | + | ||
− | Begin[ | + | Begin["System`Private`"] |
Unprotect[$SoundDisplayFunction] | Unprotect[$SoundDisplayFunction] | ||
第96行: | 第74行: | ||
$SoundDisplayFunction = | $SoundDisplayFunction = | ||
− | Module[{playCmd,soundFileName}, | + | Module[{playCmd,soundFileName}, |
− | Display[$SoundDisplay, #1]; | + | Display[$SoundDisplay, #1]; |
− | + | ||
− | (* is there a way to get the sample rate, etc. from the audio stream? *) | + | (* is there a way to get the sample rate, etc. from the audio stream? *) |
− | playCmd = "artsplay"; | + | playCmd = "artsplay"; |
− | soundFileName = "/dev/shm/" <> ToString[Unique[ | + | soundFileName = "/dev/shm/" <> ToString[Unique["sound"]] <> ".wav"; |
− | playCmd = playCmd <> " " <> soundFileName; | + | playCmd = playCmd <> " " <> soundFileName; |
− | + | ||
− | Export[soundFileName, #1, "WAV"]; | + | Export[soundFileName, #1, "WAV"]; |
− | Run[playCmd]; | + | Run[playCmd]; |
− | Run["/bin/rm -f " <> soundFileName]; | + | Run["/bin/rm -f " <> soundFileName]; |
− | ] & | + | ] & |
Protect[$SoundDisplayFunction] | Protect[$SoundDisplayFunction] | ||
第115行: | 第93行: | ||
Then add the following to <code><nowiki>~/.Mathematica/Kernel/init.m</nowiki></code> | Then add the following to <code><nowiki>~/.Mathematica/Kernel/init.m</nowiki></code> | ||
<pre><nowiki> | <pre><nowiki> | ||
− | Get[ | + | Get["sound.m"]; |
</nowiki></pre> | </nowiki></pre> | ||
Try using <code><nowiki>Play[]</nowiki></code> to see if it worked. | Try using <code><nowiki>Play[]</nowiki></code> to see if it worked. | ||
− | |||
The command to start aRts could be placed in <code><nowiki>init.m</nowiki></code> (personally, I start it in ~/.xsession). If you put it in <code><nowiki>init.m</nowiki></code>, then you'll probably want to suppress any error messages like this | The command to start aRts could be placed in <code><nowiki>init.m</nowiki></code> (personally, I start it in ~/.xsession). If you put it in <code><nowiki>init.m</nowiki></code>, then you'll probably want to suppress any error messages like this | ||
<pre><nowiki> | <pre><nowiki> | ||
第124行: | 第101行: | ||
</nowiki></pre> | </nowiki></pre> | ||
If you don't like aRts, by all means use a different command to play the sounds. The <code><nowiki>sound.m</nowiki></code> file is pretty easy to follow. | If you don't like aRts, by all means use a different command to play the sounds. The <code><nowiki>sound.m</nowiki></code> file is pretty easy to follow. | ||
− | |||
<code><nowiki>sound.m</nowiki></code> uses <code><nowiki>/dev/shm</nowiki></code> as a temporary directory. This means that it's fast, but also can't handle huge sound files. Change <code><nowiki>/dev/shm</nowiki></code> to, say, <code><nowiki>/tmp</nowiki></code> or <code><nowiki>~/tmp</nowiki></code> if you're concerned. | <code><nowiki>sound.m</nowiki></code> uses <code><nowiki>/dev/shm</nowiki></code> as a temporary directory. This means that it's fast, but also can't handle huge sound files. Change <code><nowiki>/dev/shm</nowiki></code> to, say, <code><nowiki>/tmp</nowiki></code> or <code><nowiki>~/tmp</nowiki></code> if you're concerned. | ||
− | |||
=== SMP Machines === | === 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 <code><nowiki>LinearSolve[]</nowiki></code>. You have an SMP machine if <code><nowiki>/proc/cpuinfo</nowiki></code> lists more than one processor. The work around is to set an environment variable before launching Mathematica: | 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 <code><nowiki>LinearSolve[]</nowiki></code>. You have an SMP machine if <code><nowiki>/proc/cpuinfo</nowiki></code> lists more than one processor. The work around is to set an environment variable before launching Mathematica: | ||
<pre><nowiki> | <pre><nowiki> | ||
第138行: | 第112行: | ||
</nowiki></pre> | </nowiki></pre> | ||
does the same. | does the same. | ||
− | + | === [: 215: ===: unexpected operator == | |
+ | After upgrading to Ubuntu 7.10 starting the kernel in Mathematica 5.2 produced the following error message twice | ||
+ | <pre><nowiki> | ||
+ | [: 215: ==: unexpected operator | ||
+ | </nowiki></pre> | ||
+ | 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 "Math``Kernel" scripts in Mathematica5.2/Executables from | ||
+ | <pre><nowiki> | ||
+ | #!/bin/sh | ||
+ | </nowiki></pre> | ||
+ | to | ||
+ | <pre><nowiki> | ||
+ | #!/bin/bash | ||
+ | </nowiki></pre> | ||
=== X.org Composite Extension === | === X.org Composite Extension === | ||
− | |||
Mathematica uses the Motif library (or some variant of it) to do its GUI. Motif and its variants seem to have trouble with the X.org Composite extension, which is used by xcompmgr, Xgl, Compiz, etc. It appears that just loading Composite when starting X is enough to trigger the bug; you don't have to use xcompmgr or any other compositor. This bug affects other applications (e.g. Nedit) that use a Motif variant, and is not really a bug in Mathematica. The bug basically causes bad updates to the notebook interface. If you drag the scroll bar, it will "bleed" instead of just moving. It is enough to resize the window or page up or down to cause a full redraw and fix the display, but it is very annoying. A possible workaround is | Mathematica uses the Motif library (or some variant of it) to do its GUI. Motif and its variants seem to have trouble with the X.org Composite extension, which is used by xcompmgr, Xgl, Compiz, etc. It appears that just loading Composite when starting X is enough to trigger the bug; you don't have to use xcompmgr or any other compositor. This bug affects other applications (e.g. Nedit) that use a Motif variant, and is not really a bug in Mathematica. The bug basically causes bad updates to the notebook interface. If you drag the scroll bar, it will "bleed" instead of just moving. It is enough to resize the window or page up or down to cause a full redraw and fix the display, but it is very annoying. A possible workaround is | ||
<pre><nowiki> | <pre><nowiki> | ||
第146行: | 第131行: | ||
</nowiki></pre> | </nowiki></pre> | ||
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. | 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. | ||
− | |||
=== Numlock / Alt / Ctrl / Backspace Problems === | === Numlock / Alt / Ctrl / Backspace Problems === | ||
− | |||
There are well known problems with Mathematica and X keymaps. One particular problem is an inability to use Mathematica with Numlock on (which is probably one of the more useful keys for a mathematics package...). This can be fixed with various combinations of Xresources and <code><nowiki>xmodmap</nowiki></code>. It should be enough to set some Xresources. Add the following to a file called <code><nowiki>~/.Xresources</nowiki></code>: | There are well known problems with Mathematica and X keymaps. One particular problem is an inability to use Mathematica with Numlock on (which is probably one of the more useful keys for a mathematics package...). This can be fixed with various combinations of Xresources and <code><nowiki>xmodmap</nowiki></code>. It should be enough to set some Xresources. Add the following to a file called <code><nowiki>~/.Xresources</nowiki></code>: | ||
<pre><nowiki> | <pre><nowiki> | ||
第162行: | 第145行: | ||
*secondaryModifierMask: Mod3Mask | *secondaryModifierMask: Mod3Mask | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
Then set them with | Then set them with | ||
<pre><nowiki> | <pre><nowiki> | ||
第171行: | 第153行: | ||
xrdb -merge ~/.Xresources | xrdb -merge ~/.Xresources | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
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. | 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 <code><nowiki>xmodmap</nowiki></code>, which is used to (re)define keymappings. The following works for [[UbuntuHelp:Jpkotta| 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). | The other thing to look at is <code><nowiki>xmodmap</nowiki></code>, which is used to (re)define keymappings. The following works for [[UbuntuHelp:Jpkotta| 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). | ||
<pre><nowiki> | <pre><nowiki> | ||
第182行: | 第162行: | ||
xmodmap -e "remove lock = Caps_Lock" | xmodmap -e "remove lock = Caps_Lock" | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
− | |||
− | |||
=== Locale Errors === | === Locale Errors === | ||
− | |||
The bug manifests itself with: | The bug manifests itself with: | ||
* error complaining about the locale settings | * error complaining about the locale settings | ||
第192行: | 第168行: | ||
* window list applet got stuck when the splash screen appeared | * window list applet got stuck when the splash screen appeared | ||
* segmentation fault & Mathematica death | * segmentation fault & Mathematica death | ||
− | |||
A workaround is: | A workaround is: | ||
<pre><nowiki> | <pre><nowiki> | ||
第200行: | 第175行: | ||
sudo ln -s /usr/share/X11/locale/ locale | sudo ln -s /usr/share/X11/locale/ locale | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
Also, the <code><nowiki>-noSplashScreen</nowiki></code> option should be used when starting Mathematica. | Also, the <code><nowiki>-noSplashScreen</nowiki></code> option should be used when starting Mathematica. | ||
− | + | === AMD 64 Users on Ubuntu 5.10 === | |
− | == AMD 64 Users | + | Simply due to the architecture difference, Mathematica will complain with: |
− | + | <pre><nowiki> | |
− | Simply due to the architecture difference, Mathematica will complain with | + | #/usr/local/bin/MathKernel |
− | <pre><nowiki>#/usr/local/bin/MathKernel | + | |
MathKernel cannot determine operating system.</nowiki></pre> | MathKernel cannot determine operating system.</nowiki></pre> | ||
− | + | This can be remedied with this procedure: | |
− | + | * First, add the following lines to the "math" script using your favorite editor: | |
− | + | <pre><nowiki> | |
− | + | x86_64) | |
− | * First, | + | SystemIDList="Linux";;</nowiki></pre> |
− | + | so that part of the script looks like this: | |
− | <pre><nowiki> | + | <pre><nowiki> |
− | SystemIDList="Linux";;</nowiki></pre> | + | # Determine the SystemID by examining the output of `uname -s` and |
− | + | ||
− | <pre><nowiki># Determine the SystemID by examining the output of `uname -s` and | + | |
# `uname -m`. Failsafe to SystemID=Unknown. | # `uname -m`. Failsafe to SystemID=Unknown. | ||
if [ -z "${SystemIDList}" ]; then | if [ -z "${SystemIDList}" ]; then | ||
− | case `uname -s` in | + | case `uname -s` in |
− | AIX) | + | AIX) |
− | SystemIDList="AIX-Power64 IBM-RISC";; | + | SystemIDList="AIX-Power64 IBM-RISC";; |
− | HP-UX) | + | HP-UX) |
− | SystemIDList="HPUX-PA64 HP-RISC";; | + | SystemIDList="HPUX-PA64 HP-RISC";; |
− | IRIX) | + | IRIX) |
− | SystemIDList="SGI";; | + | SystemIDList="SGI";; |
− | Linux) | + | Linux) |
− | case `uname -m` in | + | case `uname -m` in |
− | alpha) | + | alpha) |
− | SystemIDList="Linux-AXP";; | + | SystemIDList="Linux-AXP";; |
− | ia64) | + | ia64) |
− | SystemIDList="Linux-IA64";; | + | SystemIDList="Linux-IA64";; |
− | i?86) | + | i?86) |
− | SystemIDList="Linux";; | + | SystemIDList="Linux";; |
− | # Beginning of AMD64 Modification | + | # Beginning of AMD64 Modification |
− | x86_64) | + | x86_64) |
− | SystemIDList="Linux";; | + | SystemIDList="Linux";; |
− | # End Modification | + | # End Modification |
− | *) | + | *) |
− | SystemIDList="Unknown";; | + | SystemIDList="Unknown";; |
− | esac;; | + | esac;; |
− | OSF1) | + | OSF1) |
− | SystemIDList="DEC-AXP";; | + | SystemIDList="DEC-AXP";; |
− | SunOS) | + | SunOS) |
− | SystemIDList="UltraSPARC Solaris";; | + | SystemIDList="UltraSPARC Solaris";; |
− | *) | + | *) |
− | SystemIDList="Unknown";; | + | SystemIDList="Unknown";; |
− | esac | + | esac |
fi</nowiki></pre> | fi</nowiki></pre> | ||
− | + | * Next, run "math" and enter all of your registration and licensing information. | |
− | * Next | + | ''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 <code><nowiki>Segmentation Fault</nowiki></code>.'' |
− | ''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 | + | |
* Finally, make the same exact addition to the "mathematica" script. | * 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. | |
− | Now you should be able to run the "mathematica" script and have the GUI start up properly. | + | |
− | + | ||
== External Links == | == External Links == | ||
− | + | http://support.wolfram.com/ | |
− | 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) | 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) | ||
− | |||
− | |||
− | |||
[[category:UbuntuHelp]] | [[category:UbuntuHelp]] |
2009年11月17日 (二) 19:55的最新版本
点击翻译: |
English |
请不要直接编辑翻译本页,本页将定期与来源同步。 |
<<Include(Tag/StyleCleanup)>> Mathematica is not free software, see ['UbuntuScience'] for alternatives.
目录
Installation
Mathematica has an installer named Math'Installer. It is in
/cdrom/Unix/Installers/Linux
Math'Installer 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 Math'Installer:
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.
Known Issues and Workarounds
Environment Variables
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
Or you can make a launcher script like this:
#!/bin/sh VARIABLE1=value1 VARIABLE2=value2 Mathematica -option1 -option2
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]; ] & Protect[$SoundDisplayFunction] End[];
Then add the following to ~/.Mathematica/Kernel/init.m
Get["sound.m"];
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
does the same.
= [: 215: ===: unexpected operator
After upgrading to Ubuntu 7.10 starting the kernel in Mathematica 5.2 produced the following error message twice
[: 215: ==: unexpected operator
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 "Math``Kernel" scripts in Mathematica5.2/Executables from
#!/bin/sh
to
#!/bin/bash
X.org Composite Extension
Mathematica uses the Motif library (or some variant of it) to do its GUI. Motif and its variants seem to have trouble with the X.org Composite extension, which is used by xcompmgr, Xgl, Compiz, etc. It appears that just loading Composite when starting X is enough to trigger the bug; you don't have to use xcompmgr or any other compositor. This bug affects other applications (e.g. Nedit) that use a Motif variant, and is not really a bug in Mathematica. The bug basically causes bad updates to the notebook interface. If you drag the scroll bar, it will "bleed" instead of just moving. It is enough to resize the window or page up or down to cause a full redraw and fix the display, but it is very annoying. A possible workaround is
export XLIB_SKIP_ARGB_VISUALS=1
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.
Numlock / Alt / Ctrl / Backspace Problems
There are well known problems with Mathematica and X keymaps. One particular problem is an inability to use Mathematica with Numlock on (which is probably one of the more useful keys for a mathematics package...). This can be fixed with various combinations of Xresources and xmodmap
. It should be enough to set some Xresources. Add the following to a file called ~/.Xresources
:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! XMathematica settings ! system resources set in: ! /usr/local/Wolfram/Mathematica/5.1/SystemFiles/FrontEnd/SystemResources/X/XMathematica ! Set these if you need to change what the FE uses for Primary (Command) ! and Secondary (Option) modifier keys. ! this is an alternative to using xmodmap to redefine Mod3 (default NumLock) !*primaryModifierMask: Mod2Mask *secondaryModifierMask: Mod3Mask
Then set them with
xrdb -merge ~/.Xresources
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 -e "keycode 115 = Super_L" xmodmap -e "keycode 116 = Super_R" xmodmap -e "keycode 117 = Menu" xmodmap -e "add mod4 = Super_L Super_R" xmodmap -e "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
Also, the -noSplashScreen
option should be used when starting Mathematica.
AMD 64 Users on Ubuntu 5.10
Simply due to the architecture difference, Mathematica will complain with:
#/usr/local/bin/MathKernel MathKernel cannot determine operating system.
This can be remedied with this procedure:
- First, add the following lines to the "math" script using your favorite editor:
x86_64) SystemIDList="Linux";;
so that part of the script looks like this:
# Determine the SystemID by examining the output of `uname -s` and # `uname -m`. Failsafe to SystemID=Unknown. if [ -z "${SystemIDList}" ]; then case `uname -s` in AIX) SystemIDList="AIX-Power64 IBM-RISC";; HP-UX) SystemIDList="HPUX-PA64 HP-RISC";; IRIX) SystemIDList="SGI";; Linux) case `uname -m` in alpha) SystemIDList="Linux-AXP";; ia64) SystemIDList="Linux-IA64";; i?86) SystemIDList="Linux";; # Beginning of AMD64 Modification x86_64) SystemIDList="Linux";; # End Modification *) SystemIDList="Unknown";; esac;; OSF1) SystemIDList="DEC-AXP";; SunOS) SystemIDList="UltraSPARC Solaris";; *) SystemIDList="Unknown";; esac fi
- 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
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)