Objective: remove the output of a particular code cell.
Notebook name: acme
Code cell with tag ‘remove_cell’:
print(“Hello World”)
jupyter nbconvert --version
6.4.4
TEST 1:
jupyter nbconvert --to=html --no-input acme.ipynb
RESULT 1: “Hello World” in output (as expected)
TEST 2 (remove cell using cell tag):
jupyter nbconvert --to=html --no-input -TagRemovePreprocessor.remove_cell_tags=’{“remove_cell”}’ acme.ipynb
RESULT 2:
lib\site-packages\traitlets\traitlets.py:2202: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use ‘{remove_cell}’ instead of “’{remove_cell}’” if you require traitlets >=5.
warn(
Fail: The “Hello World” output is not removed.
TEST 3 (try alternate syntax):
jupyter nbconvert --to=html --no-input -TagRemovePreprocessor.remove_cell_tags=’{remove_cell}’ acme.ipynb
RESULT 3:
lib\site-packages\traitlets\traitlets.py:2202: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use ‘{remove_cell}’ instead of “’{remove_cell}’” if you require traitlets >=5.
warn(
No change in output. The “Hello World” output is not removed.
TEST 4 (use regex):
jupyter nbconvert --to=html --RegexRemovePreprocessor.patterns="[‘World’]" acme.ipynb
RESULT 4:
lib\site-packages\traitlets\traitlets.py:2562: FutureWarning: --RegexRemovePreprocessor.patterns=[‘World’] for containers is deprecated in traitlets 5.0. You can pass --RegexRemovePreprocessor.patterns item
… multiple times to add items to a list.
warn(
Hello World is still displayed
TEST 5 (try alternate syntax):
jupyter nbconvert --to=html --RegexRemovePreprocessor.patterns=World acme.ipynb
RESULT 5: No error messages, but also Hello World still displayed