pythonjupyter-notebookipythonnbconvert

How to run an .ipynb Jupyter Notebook from terminal?


I have some code in a .ipynb file and got it to the point where I don't really need the "interactive" feature of IPython Notebook. I would like to just run it straight from a Mac Terminal Command Line.

Basically, if this were just a .py file, I believe I could just do python filename.py from the command line. Is there something similar for a .ipynb file?


Solution

  • From the command line you can convert a notebook to python with this command:

    jupyter nbconvert --to python nb.ipynb
    

    https://github.com/jupyter/nbconvert

    You may have to install the python mistune package:

    sudo pip install -U mistune