Skip to content
Advertisement

Converting .py files to .ipynb

My organisation converts any Jupyter Notebooks (.ipynb files) it makes into python scripts (.py files) for easier management in our repos. I need to convert them back so I can run the notebooks but can’t work out how.

I believe they’ve been encoded using the nbconvert package but I couldn’t find a way to convert the files back in the package docs.

I’ve included the head of one of the .py files bellow in case it makes the encoding format more obvious.

JavaScript

Advertisement

Answer

Looks like the file was actually converted using program jupytext.

To convert it back I found running jupytext --to ipynb my_file.py worked.

More simply: opening the .py file in jupyter notebook allowed me to view the .py file as if it were a .ipynb file without converting.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement