How to (intermittently) skip certain cells when running IPython notebook?
Though this isn't exactly what you seem to be looking for, if you wish to entirely omit the execution of a cell (where no cached results are loaded), you can add the following hack at the beginning of a cell (assuming you are using a unix-based OS):
%%script false
or a variant (working as of early 2020 -- see here for explanation) :
%%script false --no-raise-error
Currently, there is no such feature included in the IPython notebook. Nevertheless, there are some possibilities to make your life easier, like:
use the
%store
or maybe better the%%cache
magic (extension) to store the results of these intermittently cells, so they don't have to be recomputed (see https://github.com/rossant/ipycache)add a
if==0:
before the cells you don't want to executeconvert these cells to raw cells (but you will loose the already stored output!)
(see discussion at https://github.com/ipython/ipython/issues/2125)
Jakob
If no cached results are expected to be loaded, I find the Freeze
nbextension quite useful to this end.
Although unofficial, I strongly recommend to give these notebook extensions a try if you have never used them before.
To install the extension machinery,
$ pip install jupyter_contrib_nbextensions && jupyter contrib nbextension install
To enable the Freeze
extension, launch jupyter notebook
and open a new notebook, from the menu select Edit
> nbextensions config
, and then check Freeze
.