Converting a Jupyter notebook to the latest version

Make your old notebook shiny and new again with one simple command

Sometimes, when opening a Jupyter notebook, you may encounter an error telling you it needs to be updated to the latest version. The following command takes the file old-notebook.ipynb, updates it to the latest version, and saves the result to the file new-notebook.ipynb in the ../results folder:

jupyter nbconvert 
    --to notebook old-notebook.ipynb 
    --output ../results/new-notebook.ipynb 

Execute this command via a Cloud Workstation, then download the resulting new-notebook.ipynb from the /results folder, close Cloud Workstation, and upload the notebook back to you capsule, replacing the old one. (These steps are necessary because Cloud Workstation sessions are not designed to sync back files stored in your /results folder.)

How can I convert many notebooks at once?

Use a bash script. Place all notebooks in the /code pane and execute the following in a shell script (file ending with extension .sh ):

for i in $(ls *.ipynb ); 
do  jupyter nbconvert 
    --to notebook $i 
    --output ../results/$idone

Remember to repeat the sequence of downloading the files from Cloud Workstation, then re-uploading them to your capsule.

Last updated