Installing Octave 4.2.1 on macOS Sierra

I’ve been using version 4.0.3 of Octave for some time, installed via the binary available from SourceForge. It works reasonably well, with the exception of having to return to Terminal to enter commands for paged output. I wanted to move up to the current version and managed to get version 4.2.1 installed using HomeBrew. In case you are interested, here are the steps I followed:

  1. Open Terminal
  2. Enter the command: /usr/bin/ruby -e “$(curl -fsSL”
  3. Press RETURN
  4. Install homebrew/science using the following command: brew tap homebrew/science
  5. Octave requires XQuartz, install using: brew cask install XQuartz
  6. Install Octave using the following command: brew install octave
  7. Wait for a bit, then installation finishes

At this point, I “cd’ed” to the bin directory and attempted to run Octave with the following command:

cd /usr/local/Cellar/octave/4.2.1_2/bin/

Sadly, this produced the following error:

dyld: Library not loaded: /usr/local/opt/hdf5/lib/libhdf5.100.dylib
  Referenced from: /usr/local/Cellar/octave/4.2.1_2/libexec/octave/4.2.1/exec/x86_64-apple-darwin16.5.0/octave-gui
  Reason: image not found
octave exited with signal 6

After some poking around Brew’s install of Octave, I noticed the library in question (located at: /usr/local/opt/hdf5/lib/) had been updated to version 101 (libhdf5.101.dylib), instead of the expected 100 version. I also noticed there was a symlink from libhdf5.dylib to libhdf5.101.dylib. So I just duplicated that symlink, renamed it libhdf5.100.dylib and reran the ./octave command. Everything works!


P.S. I made a small text file that contains the following:

# Runs Octave 4.2.1


and saved it to the Desktop with the filename Octave.command. Then in Terminal, I made it executable by running the following: chmod +x Octave.command

You can now double-click this file to run Octave!

8 thoughts on “Installing Octave 4.2.1 on macOS Sierra

  1. Anjana

    Thanks for the instructions . I followed your instructions and was able to install Octave .
    But when I run the program , gui is not coming up . I just get the octave command prompt .
    Any suggestion ?

    1. Norm Post author

      Hi Anjana,

      How are you “running” the program? I run it by issuing the following command from Terminal:


      If I want the command line version, I would need to run the following:


      I believe that is the default installation. You could check your /usr/local/bin directory. In that directory, you should see several octave links. In mine, I have a link for “octave” and “octave-4.2.1” that both point to the GUI app with two similar links that end in “-cli” that point to the command line version.

      Hopefully that helps, if not, let me know.


  2. john

    I have the same problem as Anjana. Octave runs fine but without the gui. I ran brew tap homebrew/science and then brew install octave. I have XQuartz on my machine so I skipped that part. In my usr/local/bin directory are the following: octave, octave-4.2.1, octave-cli, octave=cli-4,2.2.1. All of these run Octave but without the gui. any more suggestions?

  3. john

    As another attempt, I uninstalled octave using brew and reinstalled it using MacPort. Everything works fine now. I got the same 4 executables but they work as expected. Sorry to bug you with this. Thanks.

  4. James

    I have the same issues as the two above. I followed you directions, but only the cli seems to execute. No GUI..

    Any additional thoughts about this?

    1. Oliver Brodwolf

      Giordy’s tip works on macOS Sierra.
      At the end used this command to switch to the qt version.
      brew switch octave HEAD-2706adccf4e9_7


Leave a Reply

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