Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download a .py file from Jupyter lab notebook?

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.

like image 509
Tarun Kumar Yellapu Avatar asked Feb 12 '19 09:02

Tarun Kumar Yellapu


2 Answers

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.

like image 192
VijayKillu Avatar answered Oct 18 '22 11:10

VijayKillu


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:

like image 27
Ajay Rawat Avatar answered Oct 18 '22 13:10

Ajay Rawat