Search code examples
pythonjupyter-notebookipythonnbconvert

Convert JSON IPython notebook (.ipynb) to .py file


How do you convert an IPython notebook file (json with .ipynb extension) into a regular .py module?


Solution

  • From the notebook menu you can save the file directly as a python script. Go to the 'File' option of the menu, then select 'Download as' and there you would see a 'Python (.py)' option.

    enter image description here

    Another option would be to use nbconvert from the command line:

    jupyter nbconvert --to script 'my-notebook.ipynb'
    

    Have a look here.