If you are taking Andrew Ng’s Machine Learning class on Coursera this Spring, it’s about time that you set-up GNU Octave on your computer. I have done my fair share of googling, but could not find a comprehensive guide to install the latest version of Octave on Mac OS X 10.7/10.8 (Lion / Mountain Lion) using my favorite package manager for Mac, Homebrew.
The class website offers a help page for installing Octave. However, I wanted to go a little bit further from the provided installer. The Octave Wiki site offers a good starting point for installing Octave on your Mac. If you want to install Octave using MacPorts, Tom Lous posted his setup here.
Before you start, estimate this process to take at least a few hours. Make sure you’re comfortably at home, with power, internet and coffee/snacks while installation goes through. This will be the perfect time to finish watching week 1 & 2 lectures.
Command Line Tools for Xcode & XQuartz
Homebrew requires to have Command Line Tools for Xcode set-up on your Mac. If you have (and use) a current version of Xcode for development, you can install the CL Tools by going to Xcode > Preferences… > Downloads > Components. if not, I recommend the following method:
- Uninstall Xcode first (paste the command below in the Terminal)
sudo /Developer/Library/uninstall-devtools --mode=all
- Download the standalone installer from Apple (need Apple ID, ~150MB download) and install from the .dmg file
Homebrew Package Manager
If you are familiar with Linux, you probably know what a package manager is. Homebrew is an open-source package manager for Mac, for easy installation of software and tools.
- Go to the Homebrew site for reference, and follow the installation instructions, or paste/enter the following at the command prompt:
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
- Check for any issues with:
Now, we will use the Homebrew package manager to install Octave.
- Import Homebrew Science packages
brew tap homebrew/science
- Update Homebrew to the latest package definitions
- Install Octave (takes a few hours)
brew install octave
- Install the Gnuplot tool
brew install gnuplot
brew install ghostscript
- Create an Octave configuration file in your home directory
echo "setenv GNUTERM x11" > ~/.octaverc
- and finally, restart your computer
Now you have the latest version of Octave running on your machine. To start using Octave, just type
at the Terminal command prompt
Feel free to discuss this post in the comments below. Let me know how this works out for you!
#Updated August 19, 2013: octave installs dependencies automatically. Removed “brew install gfortran”