In jupyter notebook, there is a provision to download a notebook as .py file. In jupyter lab, there is an option called export as which does not contain an option to download a .py file. Is there any workaround for this, instead of copying the script in the notebook and pasting it in a python file.
Asked
Active
Viewed 2.9k times
2 Answers
36
In Jupyter lab, go to File Menu. Select "Export Notebook as" and then choose the "Export Notebook to Executable Script" option.
For Jupyter notebook, there is "Download as" option in File menu of Jupyter notebook. You can select Python (.py) from the list of available options.

VijayKillu
- 606
- 5
- 8
-
The question is for jupyter lab. – Tarun Kumar Yellapu Feb 12 '19 at 10:18
-
@TarunKumarYellapu I've updated my answer for exporting in Jupyter lab. – VijayKillu Feb 12 '19 at 10:29
-
This will export the `.py` file, removing all the structure (e.g. cells). Is there not a way to download as `.ipynb`? – Frank Meulenaar Apr 16 '19 at 12:48
-
2"Export Notebook to Executable Script" in my mac saves a .py.html file. No python executable – JFerro Oct 14 '19 at 23:07
-
You should be able to run the file by removing the `.html` extension. It's a Safari thing. – Paul Oct 01 '20 at 05:17
-
While it is an executable script, they hid that one really really well (considering the fact that in Jupyter Notebook (not Lab), it's simply "Download as .py") – Alaa M. May 04 '22 at 10:40
1
From the jupyter docs: (https://jupyterlab.readthedocs.io/en/stable/user/export.html) JupyterLab allows you to export your jupyter notebook files (.ipynb) into other file formats such as:
Asciidoc .asciidoc
HTML .html
Latex .tex
Markdown .md
PDF .pdf
ReStructured Text .rst
Executable Script .py
Reveal.js Slides .html
To access these options, while a notebook is open, browse the File menu:

Ajay Rawat
- 161
- 2
- 12
-
It would be helpful if they put the .py extension in the menu label. "Executable Script" feels like a .exe file. – Bruce Seymour Jan 29 '23 at 01:25