View or edit on GitHub
This page is synchronized from doc/JupyterHub.md. Last modified on 2025-12-09 00:30 CET by Trase Admin.
Please view or edit the original file there; changes should be reflected here after a midnight build (CET time),
or manually triggering it with a GitHub action (link).
JupyterHub
Running notebooks from the command line
It can be useful to execute notebooks from the command line.
This makes it easier to run many using e.g. screen.
jupyter nbconvert --to notebook --execute --inplace my_notebook.ipynb
You may also need to add the option --ExecutePreprocessor.timeout=-1 to remove timeouts.
Making outputs visible in GitHub
It is useful to be able to output Jupyter notebooks in a format that is viewable on GitHub. To do this, ensure that you are generating static images.
If you use Plotly, then you need to configure it explicitly. Otherwise, it will use Javascript that won't be viewable in GitHub.
The easiest way to do this is to set the default renderer to PNG:
import plotly.io as pio
pio.renderers.default = "png"
Alternatively, you can do this individually for every figure:
import plotly.express as px
df = px.data.gapminder().query("country=='Canada'")
fig = px.line(df, x="year", y="lifeExp", title='Life expectancy in Canada')
fig.show("png") # <----- PNG renderer
Outputting to GitHub-Friendly Markdown
- Create a config file strip_code_inputs.py:
# strip_code_inputs.py c = get_config() c.TemplateExporter.exclude_input = True - Run nbconvert with this config:
jupyter nbconvert my_notebook.ipynb \ --to markdown \ --output my_notebook.md \ --config strip_code_inputs.py \ --log-level=ERROR