我找到了以下文章: 2013 年 3 月开始的 IPython 中的时序和分析,但我在定义和使用魔法时遇到了问题。我想知道这是否是因为文章中的某些信息不再适用。
我做了:
$ pip install line-profiler
$ pip install psutil
$ pip install memory_profiler
然后在我的 IPython 会话中我定义了:
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相关?