Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to link the interactive python window to a running jupyter notebook kernel?

I love the new functionality in VS code to connect to a remote jupter notebook server. It allows me to run jupyter in a docker container and code away...

However when plotting pandas tables, etc. the text output is not always optimal and for quick iteration it would be great to have eg. bokeh interactive plots available.

So I was thinking the following - would it be possible to start a jupyter notebook and after that connect VS Code to the corresponding kernel. Basically the way you can also connect an existing kernel for a running notebook.

the way I can do that now:

  1. start jupyter notebook server
  2. start new notebook
  3. in the notebook execute the following magic command %connect_info
  4. this returns a json bit and some intstructions - just copy the json
  5. in another bash shell I can write this json to a file called my_kernel.json and execute jupyter console --existing my_kernel.json

now I have my notebook in my browser and my console connecting to the same kernel. So any variable available in my browser is also available in my console (and vice versa).

Would something like executing step 5 be possible in VSCode to... I would love to send code from my editor window to my interactive python console and have access to that same kernel from my notebook...

like image 365
Geoffrey Stoel Avatar asked Mar 04 '19 16:03

Geoffrey Stoel


2 Answers

Currently this isn't supported. We supported connecting to a remote server, but on that remote server we start up a new untitled document that we use. We don't currently have a method to hook up to an already running kernel.

I created this issue to track it here if you want to track / upvote: https://github.com/Microsoft/vscode-python/issues/4644

like image 136
Ian Huff Avatar answered Oct 21 '22 20:10

Ian Huff


Maybe you can do it the other way:

  1. Start a kernel with VS code by connecting to a remote Jupyter server, as documented here.

  2. Start another Jupyter notebook and connect it to the existing kernel (started by VS code) using extipy.

like image 43
gdlmx Avatar answered Oct 21 '22 20:10

gdlmx