Install Octave 3 on Mac OS X El Capitan
To install GNU Octave on a Mac is not as easy as on Microsoft Windows® or GNU/Linux.
Ready-to-use App bundles are outdated and/or do not run reliably. The installation with a package manager as MacPorts or Home Brew does not work out-of-the-box.
This How-To describes how to install Octave 3.8.2 with MacPorts (Version 2.3.4) on Mac OS X 10.11 (El Capitan). It shows how to avoid pitfalls and workaround bugs. Finally it gives some hints regarding configuration.
Currently MacPorts 2.3.4 supports GNU Octave 4.0.3. That make this how-to obsolete. Refer : Install Octave 4 on Mac OS X El Capitan
I already updated the Octave Wiki based on this how-to. But that description is brief. Here you find the detailed instructions.
First: Take your time. The installation and more important, the compilation of some parts take several hours. Be patient.
About MacPorts
MacPorts is a package manager which is based on BSD-Unices.It provides UNIX programs in packages – so-called “ports” – which are not distributed by Apple. Due to the fact that MacPorts provides the sources only, it is necessary to compile them. This takes longer than just download an already compiled app bundle. But do not worry, all these is done semi-automatically by typing a few commands.
MacPorts installs the ports and itself in the directory /opt/local which you can not view by the Finder directly. But in the case of GUI-Programs MacPorts provides App Bundles in the Program directory for easy access.
Install MacPorts
- We need the “Xcode Developer Tools” first. Since OS X 10.9 (Mavericks) you do not need to install Xcode to get the “Xcode Developer Tools”. Open a Terminal (Applications/Utilities) and type the following command:
xcode-select --install
and follow the displayed instructions to install the tools . Then type:
sudo xcodebuild -license
and confirm with “agree” and ENTER.
- Now download MacPorts for your Mac OS X version and run the PKG-installer.
- After the installation process finished MacPorts is installed on your Mac.
Install the “Octave” Port
Had you already tried to install Octave via MacPorts and it failed? Before you proceed you need to tidy up. In this case type in the Terminal:
sudo port clean atlas sudo port clean octave
otherwise you can skip the above commands. Now proceed with the following instructions.
- The port “atlas” – an import math library – does not compile with the default variant. You need to to choose the gcc5 variant. Type in the Terminal:
sudo port install atlas +gcc5
Note: The compilation of “atlas” lasts for a lot of hours, even on modern hardware. I recommend to run this command over night.
- Another dependency of Octave which could make problems later by using Octave is the math library “arpack”. Per default it will be compiled with Apple’s accelerate variant which is buggy. Compile it with atlas:
sudo port install arpack -accelerate+atlas
It is also possible to run this command after the installation of Octave.
- Now all preliminaries are finished and you can install Octave itself. If you want to use the graphical user interface (GUI) and the Java dialog functions I recommend to install Octave with the qtgui, gui and java variants:
sudo port install octave +qtgui+gui+java
The compilation of Octave lasts some time but not as much as “atlas” by far. If you need “Metis“, then do:
sudo port install octave +qtgui+gui+java+metis
- After the installation finished you find an app bundle of Octave in the Launchpad and in the directory “Applications”.It is also possible to run the command-line version of Octave in the terminal by typing the command octave.
Configure Octave
Unfortunately Octave crashes when you run a plot command. By default FLTK is used for plotting in version 3.8 but you can use Gnuplot instead. It is already installed with Octave. Type in Octave’s command line:
setenv("GNUTERM","wxt"); graphics_toolkit("gnuplot");
and try a plot, as:
sombrero()
To close the graphics window and Gnuplot together, use the close() command:
close()
otherwise a Gnuplot instance remains in memory and in the dock.
To avoid typing the commands above every time you want to plot, add them in one of Octave’s startup files, e.g. ~/.octaverc in your home directory. In general you have to create this file. Unfortunately the Finder does not allow to create a file with a preceding dot in the name (These “dot”-files are invisible in the UNIX world by default). You need to create and edit it in the Terminal:
nano ~/.octaverc
starts the editor “nano”. Then type:
setenv("GNUTERM","wxt"); graphics_toolkit("gnuplot");
in the editor and press “ctrl-x”, “y” amd ENTER to save .octaverc in your home directory and quit the editor. You find more details regarding startup files in the manual.
Rerun Octave now and try to plot.
For the Java dialog functions you need a Java JRE installed. Download it from Oracle.
Peculiarities
After starting Octave I noticed some peculiarities. Most of them are from optical nature:
- After starting Octave it gets not the focus and is hidden behind the current window. You need to bring it in front by clicking on the dock symbol or the Octave window.
- The font size of the command window is even on my non-retina Macbook to small by far. But you can correct this in the settings.
- After I finished the settings dialog box I got a warning: octave-gui[482:9528] modalSession has been exited prematurely – check for a reentrant call to endModalSession:. I need to hit ENTER first to get back to the Octave prompt.
- Labels in buttons, in the editor’s submenu and other widgets are not centered vertically (Screenshot).
- The command cd seems to be ignored in the start file ~/.octaverc. To set up a start directory fails in this case. Other commands work in .octaverc.
In comparison to the GNU/Linux or even the Windows® version Octave looks less polished on a Mac via MacPorts. I read that via Home Brew similar effects were observed.
Upgrade to Version 4
August, 14th 2016: Currently GNU Octave 4.0.3 is supported. To upgrade without any hassle refer: Octave 4 upgrade via MacPorts fails after “port upgrade outdated”.
Related Links
- Octaves Wiki
- How to install Octave on OS X Yosemite (with Home Brew)
- How to install Octave via Homebrew in Mac OS X 10.10 Yosemite and later
- Installing Octave on OS X 10.9 Mavericks (with Home Brew)
If you’re running Yosemite or El Capitan, when you run Octave the first time, you might get a notification saying “you need to install the legacy Java SE 6 runtime.” You can get that here:
https://support.apple.com/kb/DL1572?locale=en_US
I tried Homebrew first via other web tutorials and ran into a lot of problems. Mac Ports worked fine and the process described in this article worked perfectly. Thank you!
Thank you for putting together this page. This was my third install of Octave; the first two times I used the bundle and homebrew respectively. Using the bundle, octave crashed when I tried to use pinv(), and using homebrew, I couldn’t get the graphics to work with El Capitan. Everything seems to be working well!
Thanks a lot for this page, really useful.
New how-to for the current Octave 4.0.3 port published: https://blog.hani-ibrahim.de/en/octave4-mac-os-x-el-capitan-install.html
Neues How-To für den aktuellen Octave 4.0.3 Port veröffentlicht: https://blog.hani-ibrahim.de/octave4-mac-os-x-el-capitan-install.html
Pingback: GNU Octave 4 auf Mac OS X El-Capitan installieren | Hanis Sammelsurium