Claridge-Chang Lab
  • About
  • People
  • Papers
  • Join
  • Blog
  • Contact

Installing octave for ipython

12/17/2014

0 Comments

 
In late 2014, to install Octave and Oct2py for use in IPython on a Mac, take the following steps.

  1. Download the Octave binary package from Octave Forge and install

  2. Then install oct2py, by opening a terminal window and entering
    $ pip install oct2py
    as per this page.

  3. 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.

  4. 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.

  5. 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

  6. 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 ;)

0 Comments



Leave a Reply.

    Author

    ACCLab

    Archives

    September 2022
    March 2022
    February 2022
    October 2021
    September 2021
    September 2019
    March 2019
    June 2018
    May 2018
    April 2018
    March 2018
    August 2017
    January 2017
    December 2016
    October 2016
    September 2016
    August 2016
    July 2016
    May 2016
    August 2015
    July 2015
    June 2015
    May 2015
    January 2015
    December 2014
    March 2014

    Categories

    All

    RSS Feed