IPython display not displaying Markdown when notebook is run using nbconvert

1.8k Views Asked by At

I have the following in a Jupyter notebook cell:

import IPython.display as display


s = '# The World at Large'

display.display(display.Markdown(s))


s = '<b> The World at Large</b>'

display.display(display.HTML(s))

If I run it with shift+enter on the keyboard, I get:

enter image description here

However, if I execute the notebook with

jupyter nbconvert --execute --to notebook --inplace <notebook.ipynb>

I get:

enter image description here

How do I get the Markdown to display like in the first image using nbconvert?

1

There are 1 best solutions below

0
On

After you run jupyter nbconvert --execute, your notebook is in an 'untrusted' state, which I believe is the cause of the issue you're describing. You can explicitly trust the notebook by running jupyter trust <notebook.ipynb>, which will allow your markdown output to render as expected.

See also the official docs on security, and this nbconvert issue on GitHub.