Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect a Jupyter Notebook to a Spyder kernel?

The answer to the related post How to connect to an existing Jupyter Notebook kernel and inspect variables using the Variable explorer? seems to be that it's just not possible. But what if we try to connect a Jupyter Notebook to a spyder kernel? Could it then be possible to have the kernel available to the Jupyter Notebook, Spyder and the Variable explorer in Spyder?

The article Connecting Spyder IDE to a remote IPython kernel makes it sound somewhat possible:

Doing data science in Jupyter notebook is fun but sometimes you need the ability to poke into variables using the handy variable explorer in Spyder.

Connecting Spyder to a remote kernel is as straightforward as the notebooks. I will walk you through the process.

But I'm not able to reproduce the example, and I'm a bit afraid that I haven't quite understood the authors meaning with the whole article.


This is what I've tried:


1. conda install spyder-kernels works fine.

2. The same does python -m spyder_kernels.console :

enter image description here

But I'm having problems with the rest, and the article says nothing about connecting Jupyter Notebook to --existing kernel-19909.json. I'm also having problems with the part python -m spyder_kernels.console — matplotlib=’inline’ — ip=x.x.x.x -f=./remotemachine.json.

Any suggestions as to how I can take this further?

System info:

The version of the notebook server is: 5.6.0
CPython 3.7.0
IPython 6.5.0
compiler   : MSC v.1912 64 bit (AMD64)
system     : Windows
release    : 7
machine    : AMD64
CPU cores  : 8
interpreter: 64bit
like image 771
vestland Avatar asked Apr 02 '19 18:04

vestland


1 Answers

As far as I understand your question, you would like to connect IPython kernel to Spyder on your local machine. The article you mentioned describes this process for a remote connection, and I believe this was the part that confused you. First, ensure that you updated your Spyder to version 3.3.3 or newer as there used to be a bug that prevented users from seeing their variables in the explorer. These are the steps to proceed with the connection:

  1. Run python -m spyder_kernels.console and note the name of the JSON file that appears in the console output: To connect another client to this kernel, use: --existingkernel-pid.json.
  2. Open Spyder.
  3. Click on Consoles in the menu bar and select Connect to an existing kernel from the dropdown menu.
  4. In the window that opens, enter the previously noted kernel-pid.json in the Connection file prompt and click OK.

After completing these steps, a new console window with the loaded kernel will appear. You can now use it along with the Variable explorer.

like image 87
Arn Avatar answered Oct 20 '22 23:10

Arn