how to launch Spyder-Notebook programmatically from Python program run in Spyder console or Spyder-Terminal

27 views
Skip to first unread message

Rich Lysakowski

unread,
Nov 11, 2022, 7:40:42 PM11/11/22
to spyder
I am creating Jupyter Notebooks programmatically after scraping HTML-embedded Python code.  

I want to automatically (programmatically) launch Spyder-Notebook and open the ".ipynb" file that was just created in my script. 

I want to be able to follow the "nbopen" protocol: 

1) Test if there is an existing Spyder-Notebook (Jupyter?) server started by Spyder.
2) If the test result in 1) is False, then launch Spyder-Notebook
3) Pass in the NB filename, Open Spyder-Notebook, i.e., like "File...Open..."
4) Display NB in Spyder-Notebook

What API call(s) do I have to use to test if Spyder-Notebook is already running, and then open the Jupyter NB with that Jupyter server, or launch a new server if Spyder-Notebook is not already running.

Thank you.

Rich Lysakowski

Carlos Córdoba

unread,
Nov 19, 2022, 10:48:55 PM11/19/22
to spyd...@googlegroups.com

Hi,

You need to create another Spyder plugin that uses the Spyder-notebook API in the programmatic way you need.

To learn how to write plugins for Spyder, we have this tutorial. It’s a bit outdated, so you’ll also need to check how our latest plugins are implemented in the main Spyder repo.

And Spyder-notebook API is quite simple: it exposes a single method called open_notebook, which does exactly what you want when receiving a list of filenames.

Cheers,
Carlos

El 11/11/22 a las 19:40, Rich Lysakowski escribió:

--
You received this message because you are subscribed to the Google Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spyderlib+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/spyderlib/0cf528f2-d582-4c6b-9674-0a66934051adn%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages