octave4mac.featured

Install Octave 4 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 4.0.3 with MacPorts (Version 2.3.4) on Mac OS X 10.11 (El Capitan). It shows how to avoid pitfalls and workaround bugs.

The old how-to Install Octave 3 on Mac OS X El Capitan is obsolete now.

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

  1. 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.

  2. Now download  MacPorts for your Mac OS X version and run the PKG-installer.
  3. After the installation process finished MacPorts is installed on your Mac.

Install the “Octave” Port

Basic Installation

The new Octave 4.0.3 should install out-of-the-box with:

sudo port install octave

The basic installation may work for most people. But for some reasons the next lines are worth reading.

Custom Installation

The new Octave port is compiled with the accelerate variant by default. This might cause problems later. For this reason the atlas variant is a better choice. But it will consume more (compilation) time.

  1. 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.

  2. 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.

  3. Now all preliminaries are finished and you can install Octave itself. Now the graphical user interface (GUI) will be installed by default. But for using the atlas library and the Java dialog functions I recommend to install Octave with the following variants:
    sudo port install octave -accelerate+atlas+java

    The compilation of Octave lasts some time but not as much as “atlas” by far.

  4. 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.

For the Java dialog functions you need a Java JRE installed. Download it from Oracle.

Octave 4 Screenshot
GNU Octave 4.0.3 via MacPorts

Peculiarities

After starting Octave I noticed some peculiarities. Most of them are from optical nature:

  • The first plot lasts a while after starting Octave. The next one appears immediately. Windows users have the same problem.
  • 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.
  • Labels in buttons, in the editor’s submenu and other widgets are not centered vertically (Screenshot).

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.

Improvements in comparison to version 3.8.3

In comparison to version 3.8.2 some bugs and peculiarities are removed:

  • Plotting works out-of-the-box.
  • Octave gets the focus after starting now and is not coated by the current window anymore.
  • The error message after closing the settings dialog box is gone.
  • The command cd seems not to be ignored in the start file ~/.octaverc anymore.

Update Problems from 3.8.2

If you have problems from the old 3.8.3 port because of incompatible variants, refer Octave 4 upgrade via MacPorts fails after “port upgrade outdated”

Picture Credits

Public domain (CC0)

7 thoughts on “Install Octave 4 on Mac OS X El Capitan”

  1. Hi, when I tried to do basic installation for Octave using the command “sudo port install octave”, it returns an error saying that “Error: Port octave not found”. What should I do?

    1. Weird, try the command:

      port search octave

      I got a bunch of ports with “octave” in its names

      The first one is “octave @4.0.3 (math, science)”. Do you get it, too?

      If not try the following while you are connected to the Internet:

      sudo port selfupdate
      sudo port upgrade outdated

      Then try again: port search octave and check if you get the octave port.

      Then try to install octave again. But just for the case type
      sudo port clean octave before installing Octave again. You need Internet access for the latter!

      1. When I try

        “port search octave”,

        it returns

        “Warning: Can’t open index file for source: rsync://rsync.macports.org/release/tarballs/ports.tar
        Error: search for name octave failed: No index(es) found! Have you synced your port definitions? Try running ‘port selfupdate’.
        No match for octave found”.

        So I proceed to try “sudo port selfupdate” and it shows

        “—> Updating MacPorts base sources using rsync
        Error: Error synchronizing MacPorts sources: command execution failed
        Please run `port -v selfupdate’ for details.
        Error: /opt/local/bin/port: port selfupdate failed: Error synchronizing MacPorts sources: command execution failed

        1. It sounds to me as a firewall issue. Rsync cannot reach its server (rsync://rsync.macports.org/release/tarballs/ports.tar) because a (personal) firewall blocks it.

          Try another network without these restrictions, if possible. Or try to open/enable/allow port 873 (TCP) in the firewall configuration for Rsync communication.

  2. Yesterday I got Octave 4.0.3_1 to install via MacPorts as above (installing atlas and airpak beforehand) onto a new macOS 10.12 Sierra machine and all seemed to work well (at least I got no significan errors and “port installed requested” told me it got installed). Later in the day I did an “upgrade outdated” and the system eventually choked on installing Octave 4.2.0_0 after throwing up a bunch of warnings that “All compilers are either blacklisted or unavailable; defaulting to first fallback option”. I get the same failure when doing an “upgrade” as when doing a straight “install”, and yes I have done a “clean –all”.

    A possible complication is that I have not installed the full Xcode (the machine has limited storage), just the command line tools via ?”xcode-select –install”. Virtually all of the port installations warn that “Xcode does not appear to be installed; most ports will likely fail to build.” but up until this failed update, all of aquaterm, gcc5, gnuplot, xorg, grace and octave have installed without issue.

    Has anyone managed to get Octave 4.2.0_0 installed?

    I was just about to check the error log to see if it had any clues, but I foolishly “cleaned” things, so now I have to try the 20 minute install again and see what it generates.

    1. Hi Johann,

      I still have El Capitan installed and I have not updated my ports right now because I am on travel. Furthermore I use Scilab for some (toolbox) reasons now.

      Anyway, how did you installed Octave? Just “sudo port install octave” or the version with the variants?

      I guess the latter (because you installed atlas before). I think there is a incompatibility with the variants. MacPorts change the variants from version to version unfortunately. Therefor an update fails.

      I had similar problems by updating Octave from 3.8.3 to 4.0.3. For help refer my how-to: http://blog.hani-ibrahim.de/en.....ports.html. Please be advised that you cannot use this how-to word-for-word but as an template. Check whether atlas was installed correctly, also.

      Hope this helps.

      Hani

Leave a Reply

Your email address will not be published. Required fields are marked *