default module reload for Jupyter Notebook

博客介绍了IPython的自动重载魔法功能,使用%load_ext autoreload和%autoreload 2可在执行新行前重新加载所有更改的模块。还提到若想始终启用该设置,需修改IPython配置文件,给出了配置示例,同时说明了若配置文件不存在的处理方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

https://stackoverflow.com/a/5399339/8037585
IPython comes with some automatic reloading magic:

%load_ext autoreload
%autoreload 2

It will reload all changed modules every time before executing a new line. The way this works is slightly different than dreload. Some caveats apply, type %autoreload? to see what can go wrong.

If you want to always enable this settings, modify your IPython configuration file
~/.ipython/profile_default/ipython_config.py[1] and appending:

c.InteractiveShellApp.extensions = [‘autoreload’]
c.InteractiveShellApp.exec_lines = [‘%autoreload 2’]
c.InteractiveShellApp.exec_lines.append(‘print(“[WARNING] disable autoreload in ipython_config.py to improve performance.”)’)

Credit to @Kos via a comment below.

[1] If you don’t have the file ~/.ipython/profile_default/ipython_config.py, you need to call ipython profile create first. Or the file may be located at $IPYTHONDIR.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值