Ignoring ErrorsΒΆ
Normally, if an exception is raised while executing a notebook, the Sphinx build process is stopped immediately.
If a notebook contains errors on purpose (or if you are too lazy to fix them now), you can add this to the notebook’s JSON metadata:
"nbsphinx": {
"allow_errors": true
},
This very notebook is an example for this behavior. The results of the
following code cells are not stored within the notebook, therefore it is
executed during the Sphinx build process. Since the above-mentioned
allow_errors
flag is set in this notebook, all cells are executed
although most of them cause an exception.
In [1]:
nonsense
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-1-0377438312a9> in <module>() ----> 1 nonsense NameError: name 'nonsense' is not defined
In [2]:
42 / 0
--------------------------------------------------------------------------- ZeroDivisionError Traceback (most recent call last) <ipython-input-2-b75601cc3487> in <module>() ----> 1 42 / 0 ZeroDivisionError: division by zero
In [3]:
print 'Hello, world!'
File "<ipython-input-3-788c64630141>", line 1 print 'Hello, world!' ^ SyntaxError: Missing parentheses in call to 'print'
In [4]:
6 ~ 7
File "<ipython-input-4-07371befe33b>", line 1 6 ~ 7 ^ SyntaxError: invalid syntax
In [5]:
6 * 7
Out[5]:
42