Quote:
"Amigos y nadie más. El resto, la selva"
-- Jorge Guillén

How to install Octave via Homebrew in Mac OS X 10.10 Yosemite and later

From the machine-learning-scientific-and-plotting dept. (66341) (26) by Luis

Here is a very quick way to install octave with aquaterm on Mac OS X 10.10 a.k.a. Yosemite as well as 10.11 a.k.a El Capitan. Note that these steps are not for the feign of heart and your millage might vary... Follow at your own risk.

Machine Learning with Octave

updated 2016-11-21 22:32 GMT - tested with macOS Sierra (10.12) works well
updated 2015-10-07 21:58 GMT - tested with El Capitan (10.11) works well
updated 2015-06-21 09:17 GMT - adds homebrew/science tap
updated 2014-10-24 05:15 GMT - includes MacTex

First things first

Before you start you need to get your system setup. You will need:

  1. install Xcode from Apple's dev site
  2. install Xcode command line utilities from Xcode add-ons
  3. install hombrew
  4. install AquaTerm from sourceforge
  5. install Mac Latex (MacTex) from tug.org
  6. (optional) install Java

After dependencies

Yep, note that I'm assuming that you already have a working Homebrew installation, compilers, and AquaTerm ready... Then you may do:

  1. brew tap homebrew/science
  2. brew reinstall gnuplot --with-aquaterm
  3. gnuplot # make sure it says "terminal set to aqua"
  4. brew install lua51 # yes, you also need this old version of Lua
  5. brew install octave

Installing Octave will take a while and it will install Lua 2.x as a dependency. If you see the make check | tee make-check.log taking an extremely long time. You might have to open a new terminal and navigate to cd /tmp/octave* and cat make-check.log to see where it went wrong. In my case it used to stop while loading lua dynlib files but installing the older lua51 fixed it.

When updating your operating system to a newer version of MacOS (macOS now), you may need to reinstall Octave if you see an error like:

dyld: Library not loaded: /usr/local/opt/gcc/lib/gcc/5/libgfortran.3.dylib
  Referenced from: /usr/local/opt/arpack/libexec/lib/libarpack.2.dylib
  Reason: image not found
octave exited with signal 6

Try: brew reinstall gcc arpack. If that does not fix it, then try: brew reinstall octave --without-arpack. And if this fails, you may use: brew reinstall octave --with-java.

Leave a comment if you need help, but this should do the trick ;) Now you can move on with your Machine Learning studies!

Test

Here is a quick way to know everything works correctly:

  1. octave
  2. a = [2;3;4;5;6;3;4;32;3;2;1;4;5;6;7;]
  3. b = [12;23;44;55;66;12;44;9;5;27;111;23;66;89;88;]
  4. plot ([a, b])

A B plot test

Happy plotting!


Comments

  • Mark

    I get this, when trying to install octave A LaTeX distribution is required for Homebrew to install this formula.

    2014-10-23 20:12:45 UTC
  • Luis

    Mark, You're right! I forgot to include that step. I'll update the instructions.

    2014-10-24 13:06:26 UTC
  • Ryan

    Hi, Everything went fine until- brew install octave Error- No available formula for octave

    2014-10-30 23:00:45 UTC
  • George

    I already had octave and tried to do an upgrade then an uninstall/install octave but nothing seems to work. I have done steps 1 to 3 and when I do uninstall/install octave I get : make[1]: *** [all-recursive] Error 1

    2014-11-01 12:30:34 UTC
  • Alok

    With details from here and few ghostscript and ghostscript--fonts error fixed by downloading the packages and changing sha1, url link to local folders with "brew edit ghostscript" and then installing it as suggested in "[gs-bugs] [Bug 695561]" it worked. octave is back :) Thanks

    2014-11-02 17:05:42 UTC
  • Luis

    Ryan, I suspect you need to update your homebrew catalog. Did you do "brew update"?

    2014-11-11 03:47:13 UTC
  • Luis

    George, did you change any other library? Check the make log file under /tmp/octave*. 'ls -ltr /tmp' should show you the name of the octave directory as one of the last displayed.

    2014-11-11 03:52:17 UTC
  • Jim

    No available formula for veclibfort

    2014-11-12 13:52:45 UTC
  • A.J. Sutter

    I am a total novice at this sort of installation. A naive question - where do I get lua51? Does the fact that it's missing from your First things first list mean that I don't need to do anything fancy to get it, that Homebrew will find it on its own? Thanks.

    2014-11-12 15:59:35 UTC
  • Luis

    Ok, I dig a bit about some of the problems you're having (Jim and others missing formulae). The reason seems to be that you're not tapped into the science homebrew formulae. You can do so by `brew tap homebrew/science` followed by `brew install veclibfort` as explained at https://github.com/Homebrew/homebrew-science link. Jim, another reason could be that you have an older version of gfortran installed.

    2014-11-13 02:35:54 UTC
  • Luis

    A.J. Sutter, yes, that's exactly it. Once you do `brew install lua51`, Homebrew will go to the internet and find it from its reference catalog.

    2014-11-13 02:44:53 UTC
  • farout

    I tried step 5: brew install octave errored with "No available formula for octave" 4 brew tap homebrew slash science tried to save this comment says no contact link allowed homebrew and science are only separated by a / sign 5 brew -- config; brew tap; brew doctor; 6 brew install octave then octave on Yosemite 10.10.2 was able to run octave. Thank you for putting this together - saved a lot of headache.

    2015-01-30 18:05:17 UTC
  • akshay

    Thanks for the instructions. Finally I am able to install octave.

    2015-02-03 23:06:19 UTC
  • Babak

    I am doing this install on a new mac, and found I needed to add the following steps right before "brew install octave": brew tap homebrew/science install java (I used oracle's installer )

    2015-06-19 20:07:32 UTC
  • Luis

    Babak, I've updated the instructions. Thanks for sharing.

    2015-06-21 09:22:03 UTC
  • Fernando

    How cam I install Octave 4.0 in Mac OS X 10.10?

    2015-07-24 12:27:08 UTC
  • Edoardo

    Hi ! the instruction are very useful but my problem came out in that last passage since it give me an error saying that i must " brew link ghostscript" before brew can install octave. Since i am pretty new with this kind of installation i don t know what to do ! any idea ? thanks !

    2015-10-24 17:08:28 UTC
  • Andre

    Wow, this is the only thing that worked after much frustration

    2015-11-07 03:38:03 UTC
  • Scott

    I got to step 5, a couple times, and it always just hangs forever at the "make bootstrap" command. Forever being several hours. The line before "make bootstrap", which seems to work is "../configure --build=x86_64-apple-darwin15.0.0 --prefix=/usr/local/Cellar/gc". I have Xcode installed and everything else (I think). Does anybody have any ideas what could be going wrong?

    2015-11-14 17:51:18 UTC
  • Xia

    It works for me. Thanks!

    2015-12-10 01:25:58 UTC
  • Mary

    I seem to get stuck when, after trying "brew install octave", I get to "make bootstrap". It'll just run for hours with absolutely no change. I've heard that step takes a while to execute and my (2011) MacBook isn't exactly the most powerful but that seems a little silly

    2015-12-28 17:32:57 UTC
  • Tiago

    Thanks... It really works

    2016-01-01 13:35:15 UTC
  • Shubham

    How to open the Octave GUI.

    2016-03-02 03:38:02 UTC
  • HiFive

    Worked - thanks!

    2016-04-14 16:07:49 UTC
  • Damian

    I had an error with the sample code provided post installation. Fontconfig error - Cannot load default config file I found that uninstalling/reinstalling fontconfig did the trick brew uninstall fontconfig brew install fontconfig --universal HTH

    2016-04-22 23:18:55 UTC
  • Yaoyu

    Only this tutorial works for me, thanks

    2016-05-05 14:25:07 UTC

New Comment

* optional

http://example.com

Advertisement