gpt4 book ai didi

ipython Octave 魔法

转载 作者:行者123 更新时间:2023-12-02 14:00:58 34 4
gpt4 key购买 nike

我在 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/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com