Interactive Python: cannot get `%lprun` to work, although line_profiler is imported properly

后端 未结 2 1255
情深已故
情深已故 2021-01-31 08:16

Problem

Most iPython \"magic functions\" work fine for me right off the bat: %hist, %time, %prun, etc. However, I noticed that

2条回答
  •  悲哀的现实
    2021-01-31 09:01

    To make %lprun work, you need to load the extension into your session, using this command:

    In [1]: %load_ext line_profiler
    

    Check out this notebook to see some examples that use the magic.

    Besides, if you are working with Spyder, there is also a third-party line_profiler plugin, which you can find here.

提交回复
热议问题