[Tutor] Refresh library imported
Laura Creighton
lac at openend.se
Tue Aug 11 13:48:03 CEST 2015
In a message of Tue, 11 Aug 2015 10:29:56 +0200, jarod_v6--- via Tutor writes:
>HI there!!
>I try to develop some scripts. I use ipython for check if my script work.
>
>When I change the script and try to import again that script I'm not able to see the modification so I need every time close ipython and run again and import the script.
>How can do the refresh of library without close ipython?
>thanks so much!
In your Ipython prompt type
load_ext autoreload
This will get you the autoreloading extension.
Then type
%autoreload?
and read what it says about autoreload, and its limitations.
For what you want, I think you want to type:
autoreload 2
(at least that is what I have, and it works great.)
But this really is something you will want all the time, and so belongs
in your ipython config file.
So, the next question is:
Do you have an ipython config file?
Type at the shell prompt:
ipython profile create
If you didn't have them, it will make them for you, and tell you where it
put it. If it is silent you already have one, probably in your
home directory/.ipython/profile_default/ipython_config.py.
You need to find and edit the ipython_config.py file.
Don't worry about the .ipython/profile_default/ipython_nbconvert_config.py
file.
Look for these lines
# lines of code to run at IPython startup.
# c.InteractiveShellApp.exec_lines = []
change that to
# lines of code to run at IPython startup.
c.InteractiveShellApp.exec_lines = ['%autoreload 2']
Also look for
# A list of dotted module names of IPython extensions to load.
# c.InteractiveShellApp.extensions = []
change this to:
# A list of dotted module names of IPython extensions to load.
c.InteractiveShellApp.extensions = ['autoreload']
If you have an .ipython config file, and these lists aren't empty,
just add '%autoreload 2' and 'autoreload' to whatever already is there.
Hope this helps,
Laura Creighton
More information about the Tutor
mailing list