首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >IPython 2.x中的定时和特征分析

IPython 2.x中的定时和特征分析
EN

Stack Overflow用户
提问于 2014-03-05 01:29:17
回答 1查看 518关注 0票数 2

我发现了以下文章:2013年3月的IPython中的时序和特征分析,但是我在定义和使用魔法时遇到了问题。我不知道这是不是因为文章中的一些信息不再适用了。

我做了:

代码语言:javascript
复制
$ pip install line-profiler
$ pip install psutil
$ pip install memory_profiler 

然后在我的IPython会话中,我定义了:

代码语言:javascript
复制
import memory_profiler

def load_ipython_extension(ip):
    ip.define_magic('memit', memory_profiler.magic_memit)
    ip.define_magic('mprun', memory_profiler.magic_mprun)

当我试着:

%memit

我明白了:ERROR: Line magic function not defined。为什么?

另外,2013年的文章还与IPython 2.x相关吗?

EN

回答 1

Stack Overflow用户

发布于 2014-04-03 09:08:46

您还需要“注册模块”,如后面的文章所解释的那样。

编辑~/.ipython/profile_default/ipython_config.py,搜索、取消注释并修改这些列表,包括: c.TerminalIPythonApp.extensions = 'line_profiler_ext','memory_profiler_ext',c.InteractiveShellApp.extensions = 'line_profiler_ext','memory_profiler_ext',

当我定义了一个概要文件和扩展文件夹$IPythonDIR/extensions时,这对我起了作用。

不确定,如果您手动导入交互式shell中的函数,如何使其工作。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22186709

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档