In late 2014, to install Octave and Oct2py for use in IPython on a Mac, take the following steps.
Yes this would have been better as a Notebook ;)
- Download the Octave binary package from Octave Forge and install
- Then install oct2py, by opening a terminal window and entering
$ pip install oct2py
as per this page. - Python and oct2py are still not aware of Octave's location. To make them aware, edit your bash profile. As per this page, open a terminal window and enter
$ touch ~/.bash_profile; open ~/.bash_profile
This will open your bash profile in TextEdit. - To the bash profile use the method from this page; add the following line of text
export PATH=/usr/local/octave/3.8.0/bin:$PATH
You may need to adjust this text as per the version of Octave you are using. - Now as per this page you 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.]] float64 - Or you can use oct2py in IPython magic mode like
In [1]: %load_ext oct2py.ipython
In [2]: x = %octave [1 2; 3 4];
x
Out[2]: array([[ 1., 2.],
[ 3., 4.]])
as per this page.
Yes this would have been better as a Notebook ;)