简体   繁体   English

如何从IPython Notebook内部强制自动重新加载库

[英]How to force an automatic reload of the library from inside IPython notebook

I'm just learning IPython Notebook, using a pre-existing Python library I've written. 我只是在使用我已经编写的Python库来学习IPython Notebook。 At the beginning of my notebook, I'm importing it in the normal way. 在笔记本的开头,我以正常方式导入它。

However, I'm still modifying this library. 但是,我仍在修改此库。 I notice that changes I'm making to it don't seem to be reflected, even when I reload the notebook in the browser. 我注意到,即使我在浏览器中重新加载笔记本,对它所做的更改似乎也不会反映出来。

How can I force a reload of the library from inside IPython notebook? 如何强制从IPython Notebook内部重新加载库?

Use the magic autoreload to get your module refreshed automatically as you edit it. 使用魔术自动autoreload ,可以在编辑模块时自动刷新模块。

For instance, if you develop a module called mylibrary : 例如,如果您开发一个名为mylibrary的模块:

%load_ext autoreload
%autoreload 1
%aiimport mylibrary

will automatically reload the module mylibrary . 将自动重新加载模块mylibrary

You can ask to get all modules automatically reloaded with: 您可以要求自动重新加载所有模块:

%autoreload 2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM