ipython Octave 魔法

标签 ipython octave oct2py

我在 ubuntu 上使用 python 2.7

根据documentation我应该能够从 ipython 运行 Octave :

%install_ext octavemagic
%load_ext octavemagic

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

如果我尝试:

%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')

完整跟踪 here

%lsmagic提供了很多魔力,我尝试过%%timeit arange(1000)并且效果很好。

最后,我在 ipython 命令行(而不是笔记本)测试了它的魔力; %octave x = [1,2;3,4]工作得很好。

我真的很想从 ipython 笔记本上运行 Octave 音程。知道在哪里调查吗?

octavemagic.py 位于 <myinstall_directory>/IPython/extensions/octavemagic.py和我尝试过但失败的其他人一样。 我的步骤:按照http://ipython.org/ipython-doc/stable/config/extensions/octavemagic.html

  1. $ easy_install oct2py(没问题)
  2. $ easy_install h5py
    h5py/api_compat.h:21:18: fatal error: hdf5.h: No such file or directory (我确实在几个地方(octave 和另一个第 3 方库)有它。发现其他人 说 h5py 损坏了 hdf5.h,所以我尝试了完整的 lib-dev 安装)

    $sudo apt-get libhdf5-serial-dev $sudo easy_install h5py 安装/usr/local/lib/python2.7/dist-packages/h5py-2.0.1-py2.7-linux-x86_64.egg 处理 h5py 的依赖关系 完成h5py的依赖处理

  3. 发现我有一个精简版(仅限笔记本?)ipython,因此我从 git 安装了源代码并构建了它。是的。我 build 了它。 8)

  4. sudo easy_install nose pexpect irunner and ipython-dev
  5. 启动笔记本 ipython notebook -pylab inline 笔记本启动并且一切正常,除了 %magic Octavemagic 之外。也不适用于 %magic bash 或
  6. 中的其他几个

最佳答案

完全正确,octavemagic 与标准 Octave 安装捆绑在一起,因此所需要做的就是

%load_ext octavemagic

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

> ipython
vs
> ipython notebook --pylab inline

我重新启动笔记本并再次尝试。现在 %load_ext Octavemagic 可以工作了。也许我之前只是对与错误 trying to install 相关的错误感到困惑 如果 Octave 给出类似“已安装”的消息而不是链接中的回溯错误,那就太好了。

关于ipython Octave 魔法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12256390/

相关文章:

shell - 如何在 iPython shell 中撤消输入(不是命令输出)

c - 有没有一种方法可以将 graph500 生成的位图文件读取为图形文件?

audio - 鸡尾酒会-音源分离

python - 如何在 Windows 上安装 oct2py?

caching - 完全禁用 IPython 输出缓存

python - 如何从 Jupyter 4.x 获取 IPython 配置文件行为?

variables - 如何检查变量是否在 Octave 中定义?

python - Octave isnan : not defined error using oct2py

python - Anaconda/Spyder 中的 oct2py 无法识别 Octave 音程

pdf - IPython/Jupyter 下载为 PDF 样式