Dzung Nguyen
Dzung Nguyen

Reputation: 3942

Rerun import in Jupyter notebook

In jupyter notebook, I have a cell including all imports. Those imports some of my own modules.

When I rerun the cell, it does not pick up the updates in the modules. I need to to a kernel restart and rerun the whole notebook. Is there any other way to fix this problem?

Upvotes: 4

Views: 2175

Answers (1)

Lukas
Lukas

Reputation: 2480

You can also use the reload magic by placing this in your notebook. It will automatically reload code.

%reload_ext autoreload
%autoreload 2

The only time this may cause confusion is, if you instantiated an object, change the code and then wonder, why the already instantiated object does not have the new functions. Besides this case, it works well.

This question is also asked here.

Upvotes: 1

Related Questions