16

I'm running ipython qtconsole. I want to execute a file that I edit separately inside an editor. When I make changes to the file in the editor and re-run it in IPython using:

%run myfile.py

the code isn't updated. However, if I run ipython normally from the terminal then this works fine. I tried to use autoreload in the QT console:

%load_ext autoreload
%autoreload

but it doesn't fix the problem. What is wrong here?

Benjamin Hodgson
  • 42,952
  • 15
  • 108
  • 157
lgd
  • 1,472
  • 5
  • 17
  • 35
  • 1
    I can't reproduce. If I edit the file, save it and re-run, the code is updated. Can you post more information on your ipython/qtconsole version, your code and your editor ? – Mel Dec 01 '15 at 15:51

2 Answers2

1

did you try:

import importlib
importlib.reload(<module_name>)
Stéphane
  • 1,389
  • 3
  • 13
  • 34
1

You can use the general python reload instead of the ipython autoreload like:

reload(module)

Bear in mind that this will not automatically reload dependencies, so you would have reload any nested imports as well.

See this question as well

Nick
  • 138,499
  • 22
  • 57
  • 95
Aryan Jain
  • 384
  • 1
  • 7