Skip to content

Convert .ipynb to .py

pip install jupytext --upgrade


conda install -c conda-forge jupytext

Command line conversion

The package provides a jupytext script for command line conversion between the various notebook extensions:

jupytext --to py notebook.ipynb                 # convert notebook.ipynb to a .py file
jupytext --to notebook              # convert to an .ipynb file with no outputs
jupytext --to notebook --execute    # convert to an .ipynb file and run it
jupytext --update --to notebook     # update the input cells in the .ipynb file and preserve outputs and metadata
jupytext --set-formats ipynb,py notebook.ipynb  # Turn notebook.ipynb into a paired ipynb/py notebook
jupytext --sync notebook.ipynb                  # Update all paired representations of notebook.ipynb
jupytext --to notebook 
jupytext --to py Nine.ipynb

rm /tmp/spec.txt
time runipy Nine.ipynb 
real	0m52.001s

rm /tmp/spec.txt
time python
real	0m39.268s
Published inUncategorized

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *