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.

EDIT: For more current macOS versions reliable app bundles are available at octave-app.org.

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”

Related Links

Picture Credits

Public domain (CC0)


20 comments

  • 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?

    • 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!

      • 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

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

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

    • 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: https://blog.hani-ibrahim.de/en/octave4-upgrade-via-macports.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

      • My installation was:

        sudo port install aquaterm
        sudo port install gcc5
        sudo port install gnuplot
        sudo port install xorg-libXt +flat_namespace
        sudo port install grace
        sudo port install atlas +gcc5
        sudo port install arpack -accelerate+atlas+gfortran
        sudo port install qrupdate -accelerate+atlas+gcc5
        sudo port install octave -gcc5+gfortran-accelerate+atlas+docs+fltk+graphicsmagick+java-gui-metis-qtgui+app+qt4gui+sound

        And that all installed as expected, giving me Octave 4.0.3_1, it was the

        sudo port update Octave

        that failed, as has an additional

        sudo port install octave -gcc5+gfortran-accelerate+atlas+docs+fltk+graphicsmagick+java-gui-metis-qtgui+app+qt4gui+sound

        I’ll try an update on my Mac OS X 10.11 machine and maybe try doing a full Xcode installation, and take a more critical look at all the variants to make sure they are all playing nicely with each other.

        • Well, on my Mac OS X 10.11 machine, the “upgrade outdated” resulted in a working copy of Octave 4.2.0_1 with the following warning:

          unless octave is run with –no-gui-libs, graphics_toolkit(“fltk”) will cause a crash

          Maybe I should give the macOS 10.12 machine another try now that 4.2.0_1 is what is current.

          • Well, the “upgrade outdated” worked now on macOS 10.12 and got me Octave 4.2.0_1, albeit with the crash warning.

            Invoking “octave” at the command line does fire up the octave-gui process without any crash that I see. Running “octave –no-gui-libs” seems to get what is expected at the command line. All of this is working without the full Xcode, just the command line tools.

            So it looks like it is all working without me really doing anything but waiting.

          • Hi Johann, I did port selfupdate && port upgrade outdated on my machine (Mac OS X 10.11.6) now.

            It ran without any problems. Octave 4.0.2 starts with some warnings (module problem) but runs as expected. But it crashes when I try to quit the program.

            I found an incompatibility in my ~/.octaverc file. I renamed the file and Octave quits then properly.

            The problem was the call of one external module in ~/.octaverc.

  • MacPorts will no longer install or update octave on Sierra, because of a problem with transfig. Error messages suggest that there is a (new?) conflict between transfig and fig2dev.

    • Same here. I did:

      sudo port uninstall transfig
      sudo port install fig2dev
      sudo port upgrade outdated
      

      And the upgrade finished successfully.

      • As I had previously uninstalled octave, I ran your first two steps (uninstall transfig, then install fig2dev), and then I followed your “Custom Installation” steps above. That worked. Now I can run octave from the command line, as long as I use the –no-gui-libs option, as mentioned in the MacPorts note. Trying to run from Applications, or from the command line without the –no-gui-libs option, causes the program to hang (spinning beach ball) as soon as I try anything.

        • Hmm, when I run Octave from the Launchpad it works as expected in GUI-Mode. But I updated Octave I did not reinstall it. I did not changed anything concerning --no-gui-libs.

          I recommend to do sudo port upgrade outdated again. As the hint regarding Octave appeared it did not finished its work apparently.

          But to be honest, I have not checked Octave properly because I switched to Scilab.

          • Works correctly from LaunchPad. I have no idea what is the difference, but I’m not complaining. Thanks for that suggestion.

  • Pingback: GNU Octave 3 auf Mac OS X El-Capitan installieren | Hanis Sammelsurium

  • hello after trying many other options , I looked your code was working on my el captain 10.11.6 i tried following your instruction till this

    sudo port install octave -accelerate+atlas+java

    after this,in the end I get this
    Attempting to fetch texlive-pictures-54512_0+doc.darwin_15.noarch.tbz2 from http://atl.us.packages.macports.org/texlive-pictures
    Error: Failed to archivefetch texlive-pictures: version @54512_0+doc: Could not resolve host: atl.us.packages.macports.org
    Error: See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_tex_texlive-pictures/texlive-pictures/main.log for details.
    Error: Follow https://guide.macports.org/#project.tickets if you believe there
    is a bug.
    Error: Processing of port octave failed
    —> Some of the ports you installed have notes:
    gawk has the following notes:
    readline support has been removed from gawk. If you need to run gawk
    interactively, install rlwrap:

    sudo port install rlwrap

    and run gawk using rlwrap:

    rlwrap gawk …
    grep has the following notes:
    This port previously installed itself without a g* prefix, thus
    overshadowing system binaries such as grep, fgrep, and egrep. The port is
    now changed so that it does install with a g* prefix, like other GNU ports.
    This means that you’ll now find GNU grep at /opt/local/bin/ggrep. If you
    dislike typing ggrep, you can create a shell alias or you can add
    /opt/local/libexec/gnubin to your PATH, wherein non-g* prefixed symlinks are
    installed. In other words, /opt/local/libexec/gnubin contains GNU binaries
    without any prefix to the file names, so you can type grep and get GNU grep
    just as before.
    hdf5 has the following notes:
    Mac users may need to set the environment variable “HDF5_USE_FILE_LOCKING”
    to the five-character string “FALSE” when accessing network mounted files.
    This is an application run-time setting, not a configure or build setting.
    Otherwise errors such as “unable to open file” or “HDF5 error” may be
    encountered.
    legacy-support has the following notes:
    To help make sure your system continues to be well represented by MacPorts,
    especially if your system is not one of the latest macOS releases, please
    consider installing mpstats. It will periodically send an anonymous synopsis
    of your OS settings and installed ports. The information provided by this is
    useful to help determine how resources are allocated.

    You can install mpstats like this: sudo port install mpstats
    libidn has the following notes:
    Please be aware that GNU libidn2 is the successor of GNU libidn. It comes
    with IDNA 2008
    and TR46 implementations and also provides a compatibility layer for GNU
    libidn.
    libomp has the following notes:
    To use this OpenMP library:
    * For clang-3.8+, or clang-3.7 with +openmp variant:
    add “-fopenmp” during compilation / linking.
    * For clang-3.7 without +openmp variant, use:
    “-I/opt/local/include/libomp -L/opt/local/lib/libomp -fopenmp”
    libpsl has the following notes:
    libpsl API documentation is provided by the port ‘libpsl-docs’.
    openjdk8 has the following notes:
    If you have more than one JDK installed you can make openjdk8 the default
    by adding the following line to your shell profile:

    export
    JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk8/Contents/Home
    python39 has the following notes:
    To make this the default Python or Python 3 (i.e., the version run by the
    ‘python’ or ‘python3’ commands), run one or both of:

    sudo port select –set python python39
    sudo port select –set python3 python39

    should I follow and install commods as instructed or can I ignore and continue with oracle ?

  • Hello, I installed all of the commands on my terminal, but I couldn’t find octave in my launchpad, and I couldn’t open it with the command octave in the terminal.

Leave a Reply

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