Export a notebook as HTML without showing the source code so you can share results as a standalone page.
Quick reference
jupyter nbconvert --to html --no-input your_notebook.ipynb
# Safer when working inside a venv
python -m jupyter nbconvert --to html --no-input your_notebook.ipynbCreate a venv and install nbconvert
For a new virtual environment, install nbconvert first. This is enough when the notebook already has saved outputs and you only need to export them to HTML.
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install nbconvertRun the conversion through Python when you want to make sure the active venv is used.
python -m jupyter nbconvert --to html --no-input your_notebook.ipynbInstall for site workflow
For a site workflow that exports notebooks repeatedly, install nbconvert, jupyter, and ipykernel in the same venv.
python -m pip install nbconvert jupyter ipykernelExecute during conversion
If the notebook does not already have saved outputs, execute it during conversion. The venv must also contain the notebook dependencies needed by the notebook itself.
python -m pip install nbconvert ipykernel
python -m jupyter nbconvert --to html --no-input --execute your_notebook.ipynbVerify the venv tools
Check that Python, pip, and jupyter all come from the active virtual environment.
which python
which pip
which jupyter
python -m jupyter nbconvert --version
# Expected paths should point into .venv:
# /home/example-user/projects/tools/nbconvert/.venv/bin/python
# /home/example-user/projects/tools/nbconvert/.venv/bin/pip
# /home/example-user/projects/tools/nbconvert/.venv/bin/jupyterFlags
- --to html - output format
- --no-input - strips all code cells from the output, leaving only results and markdown
- --execute - runs the notebook before writing the HTML output
The output file is placed in the same directory as the notebook with a .html extension. To write to a different location:
python -m jupyter nbconvert --to html --no-input your_notebook.ipynb --output-dir ./exports