Download Spyder notebook as .py?

39 views
Skip to first unread message

Nate Deweerdt

unread,
Apr 16, 2021, 1:40:15 PM4/16/21
to spyder

This might be a simple question, but is there a way to open a jupyter notebook file in a spyder notebook and then download it as a .py file like you can do in jupyter notebooks?

Thanks,
Nate

Björn Johansson

unread,
Apr 17, 2021, 3:21:53 AM4/17/21
to spyder
You can use jupytext:

jupytext --output script.py notebook.ipynb  # convert ipynb to py

yfprojects

unread,
Apr 18, 2021, 2:25:26 AM4/18/21
to spyder
Hello,
when installing jupyter, I should come with a command called `jupyter nbconvert` or `nbconvert` or `jupyter-nbconvert`. You can use the command to convert notebooks into various different formats including python code files.

> The simplest way to use nbconvert is
>   
>    > jupyter nbconvert mynotebook.ipynb --to html
>   
> Options include ['asciidoc', 'custom', 'html', 'latex', 'markdown', 'notebook', 'pdf', 'python', 'rst', 'script', 'slides', 'webpdf'].
>
>Multiple notebooks can be given at the command line in a couple of  different ways:
>   
>   > jupyter nbconvert notebook*.ipynb
>   > jupyter nbconvert notebook1.ipynb notebook2.ipynb

Kind regards
yfprojects
Reply all
Reply to author
Forward
0 new messages