The autoupdate module in IPython / jupyter notebook

I wrote my own module, which as the following structure:

mymodule/ ├── __init__.py ├── part1.py ├── part2.py ├── part3.py └── part4.py 

To test my module, I use IPython and / or jupyter notebook (formerly Ipython Notebook). As usual, I import a module, for example

 import mymodule 

Let's say I edit the code in part2.py and want to use the updated version of my module. At first I thought that just re-importing the module using import mymodule would do the job, but it is not. To completely reboot the module, I need to close the IPython shell or restart the jupyter kernel and start again by importing mymodule .

However, referring to the docs , IPython provides an automatic update function called autoreload , which provides different modes and can be activated as follows

 %load_ext autoreload %autoreload 1 %aimport mymodule 

Using both of my fragments, I import mymodule as follows:

 %load_ext autoreload %autoreload 1 %aimport mymodule import mymodule # let do something with the module here 

However, even with activated autoreload 1 or autoreload 2 neither IPython nor jupyter do what I expect from them, and I still have to exit the IPython shell or restart the jupyter core to use the edited code part2.py which is part mymodule

What am I doing wrong? I don't seem to understand how this should work.

+5
source share
1 answer

Change %autoreload 1 to %autoreload 2 as dashy, old version or error.

+4
source

All Articles