What is autoreload
?
autoreload
loads the respective module before executing the code.
Consider if one is working in vscode
like this:
- Code in the left hand side and executing the code in right hand side in
IPython
. - As the code is developed it is executed in the IPython terminal to check it correctness.
- Without
autoreload
enabled one needs to reload the code into IPython every-time a change is made and it needs to be evaluated.
How to set autoreload
at startup?
In Windows 10:
- Press
Win+R
keys --> get run dialog - Type
%USERPROFILE%
and press enter - Navigate to .ipython folder, if you don't see one, following steps doesn't help
- From there navigate to folder
profile_default/startup
- Create a file named
001.py
-
Copy paste following lines of code in that file:
from IPython import get_ipython ipython = get_ipython() if "__IPYTHON__" in globals(): ipython.magic("load_ext autoreload") ipython.magic("autoreload 2")
Save the file and open
ipython
it shall nowautoreload
In Ubuntu:
- Open a terminal and navigate to
~/.ipython/profile_default/startup
- Follow the last three steps as in windows 10.
Top comments (0)