3

I'm on ubuntu with python 2.7

according to the documentation I should be able to get octave running from ipython:

%install_ext octavemagic
%load_ext octavemagic

('The file must have a .py or .zip extension', u'octavemagic')

If I try:

%install_ext bash.py
IOError                                   Traceback (most recent call last)
<ipython-input-5-36b60e02c7c6> in <module>()
----> 1 get_ipython().magic(u'install_ext bash.py')

Complete trace here

%lsmagic gives a lot of magics and i tried %%timeit arange(1000) and it worked fine.

Finally, I tested the magic at the ipython commandline, as opposed to notebook; %octave x = [1,2;3,4] worked just fine.

I'd really like to get octave running from ipython notebook. Any ideas of where to investigate?

octavemagic.py is in <myinstall_directory>/IPython/extensions/octavemagic.py as are the others i tried that failed. My steps: according to http://ipython.org/ipython-doc/stable/config/extensions/octavemagic.html

  1. $ easy_install oct2py (no problem)
  2. $ easy_install h5py
    h5py/api_compat.h:21:18: fatal error: hdf5.h: No such file or directory (I do have it in a couple of places (octave and another 3rd party lib. Found others who said that h5py is broken wrt hdf5.h, so I tried a full lib-dev install)

    $sudo apt-get libhdf5-serial-dev $sudo easy_install h5py Installed /usr/local/lib/python2.7/dist-packages/h5py-2.0.1-py2.7-linux-x86_64.egg Processing dependencies for h5py Finished processing dependencies for h5py

  3. Discovered I had a thin (notebook only?) version of ipython, so I installed the source from git and build it. Yes. I built it. 8)

  4. sudo easy_install nose pexpect irunner and ipython-dev
  5. launch notebook with ipython notebook -pylab inline Notebook starts and things work, except for the %magic octavemagic. Also doesn't work for %magic bash or several others in
4

1 回答 1

1

非常正确,octavemagic 与标准 octave 安装捆绑在一起,所以只需要

%load_ext 八度魔法

我的 ipython 命令行和笔记本必须相同,因为唯一的区别是:

> ipython
vs
> ipython notebook --pylab inline

我重新启动笔记本并再次尝试。现在 %load_ext octavemagic 工作。也许我之前只是被与错误地尝试安装相关的错误弄糊涂了, 如果 octave 给出类似“已经安装”的消息而不是链接中的回溯错误,那就太好了。

于 2012-09-05T17:54:43.370 回答