2

I do the following in my IPython notebook:

import sys
sys.path.append('my_directory')
from db import *

It works fine. But then I added a new function to the db.py and IPython does not see it. It OK. But it does not see it even if I reset everything end re-execute the cell that imports everything. It does not see it even if I user reload. It does not see it even if I close the IPython notebook and restart it.

What is the way to force IPython (or python) to see the updated content of the file?

nom-mon-ir
  • 3,748
  • 8
  • 26
  • 42
Roman
  • 124,451
  • 167
  • 349
  • 456
  • 1
    I think this is something you are looking for http://stackoverflow.com/questions/1907993/autoreload-of-modules-in-ipython – Andrii Zarubin Jul 25 '13 at 13:19

1 Answers1

3

You need to use autoreload. Check the manual at http://ipython.org/ipython-doc/dev/config/extensions/autoreload.html. Seems you need:

%autoreload 2

The above will automatically reload all imported modules. Except those inlcuded in a separate special list of modules specified by %aimport modulename. Those will only be autoreloaded if you specify %autoreload 1.

nom-mon-ir
  • 3,748
  • 8
  • 26
  • 42