Setting Up Autoreloading for iPython
1 min read

Setting Up Autoreloading for iPython

If you have the latest version of iPython installed >=.12 , you can reload modules automatically.

# Run the commands below in the terminal
ipython profile create # tells you where config file is located

# edit the file with vim or nano
vim ~/.ipython/profile_default/ipython_config.py # The file location can be different
# ipython_config.py 
# Change the extensions and exec_lines to include autoreload
#c.InteractiveShellApp.extensions = []
c.InteractiveShellApp.extensions = ['autoreload']
#c.InteractiveShellApp.exec_lines = []
c.InteractiveShellApp.exec_lines = ['%autoreload 2']

Now if you make edits in your code, it should reload the modules. In a testing environment, this is great, but I suggest that you do not do it in a production environment.