jupyter nbconvert --to script notebook.ipynb

Category: Data Science & Analysis

jupyter nbconvert --to script notebook.ipynb

Strip a notebook down to a plain Python script

The --to script target extracts only the code cells into a .py file, dropping markdown and outputs. The result runs with plain python3 and is easy to diff or schedule. Markdown cells are turned into comments for context. This is the standard way to move a notebook prototype into production code.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.