Installing octave for ipython

migrated
In late 2014, to install Octave and Oct2py for use in IPython on a Mac, take the following steps. Download the Octave binary package from Octave Forge and install Then install oct2py, by opening a…
Author

Adam Claridge-Chang

Published

December 17, 2014

In late 2014, to install Octave and Oct2py for use in IPython on a Mac, take the following steps.Download the Octave binary package fromOctave Forgeand installThen install oct2py, by opening a terminal window and entering\(pip install oct2pyas per[this [[[[page](http://nbviewer.ipython.org/github/blink1073/oct2py/blob/master/example/octavemagic_extension.ipynb?create=1)](https://pypi.python.org/pypi/oct2py)](https://stackoverflow.com/questions/23753081/how-do-i-add-octave-to-my-path-to-use-oct2py)](http://hathaway.cc/post/69201163472/how-to-edit-your-path-environment-variables-on-mac)](https://pypi.python.org/pypi/oct2py).Python and oct2py are still not aware of Octave's location. To make them aware, edit your bash profile. As per thispage, open a terminal window and enter\)touch ~/.bash_profile; open ~/.bash_profileThis will open your bash profile in TextEdit.To the bash profile use the method from thispage; add the following line of textexport PATH=/usr/local/octave/3.8.0/bin:$PATHYou may need to adjust this text as per the version of Octave you are using.Now as per thispageyou should be ready to either call Octave as a library of IPython, e.g.>>>from oct2py import octave as oc>>> x = oc.zeros(3,3)>>> print x, x.dtype[[ 0.  0.  0.][ 0.  0.  0.][ 0.  0.  0.]] float64Or you can use oct2py in IPython magic mode likeIn [1]: %load_ext oct2py.ipythonIn [2]: x = %octave [1 2; 3 4];xOut[2]: array([[ 1.,  2.],[ 3.,  4.]])as per thispage.Yes this would have been better as a Notebook ;)