Converter Jupyter


1. Jupytext

  • Install jupytext
# Use conda or pip
conda install -c conda-forge jupytext
  • Edit Jupyter config
# Generate a Jupyter config
jupyter notebook --generate-config

# Edit .jupyter/jupyter_notebook_config.py
vim /Users/j/.jupyter/jupyter_notebook_config.py

# Append the following
c.NotebookApp.contents_manager_class = "jupytext.TextFileContentsManager"

# Restart Jupyter Notebook
jupyter notebook
  • Convert format within Notebook
# Click Edit=>Edit Notebook Metadata and append the below line
"jupytext": {"formats": "ipynb,py"},
  • Or convert format using command line
jupytext --to py:percent notebook.ipynb         # create a notebook.py file in the double percent format
jupytext --to markdown notebook.ipynb           # create a notebook.md file
jupytext --output script.py notebook.ipynb      # create a script.py file

jupytext --to notebook notebook.py              # overwrite notebook.ipynb (remove outputs)
jupytext --to notebook --update notebook.py     # update notebook.ipynb (preserve outputs)
jupytext --to ipynb notebook1.md notebook2.py   # overwrite notebook1.ipynb and notebook2.ipynb

jupytext --to md --test notebook.ipynb          # Test round trip conversion

jupytext --to md --output - notebook.ipynb      # display the markdown version on screen
jupytext --from ipynb --to py:percent           # read ipynb from stdin and write double percent script on stdout

2. jupyter2slides

python create_slides.py --file static/filename.ipynb
python run.py --file static/filename.slides.html
http://0.0.0.0:9099/
  • change footer in jupyter_template.tpl

3. nbconvert