12

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
vestland
  • 55,229
  • 37
  • 187
  • 305

1 Answers1

1

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.

Arn
  • 1,898
  • 12
  • 26
  • Thank you for responding. I've tried your approach a few times, but it does not seem to work on my end. Also, I don't understand how it *should* work. If `python -m spyder_kernels.console` is the first step, and the next step is to open Spyder, then there's no involvment of a Jupyter Notebook here? Please enlighten med if there's something I'm missing here. – vestland Mar 05 '20 at 14:40
  • I've finally realized that although both Jupyter and Spyder are mentioned in the article [Connecting Spyder IDE to a remote IPython kernel](https://medium.com/@halmubarak/connecting-spyder-ide-to-a-remote-ipython-kernel-25a322f2b2be), the connection between the two has got *nothing* to do with eachother. The author only really shows that whats possible to do in jupyter, is also possible to do in Spyder. – vestland Mar 05 '20 at 14:46
  • Although you *can* connect Spyder to a running notebook kernel, the variables will not be available for inspection in Spyders variable explorer. – vestland Mar 05 '20 at 14:48
  • Any feedback or new info on this? As it stands, your question does not answer the question. But I *really* want to give you the bounty points. – vestland Mar 07 '20 at 17:12
  • I believe the latter part of your question was an XY problem. I haven't noticed that earlier and I attempted to help you understand the article you linked to reach the solution. Later, I tried to connect a running Jupyter notebook kernel to Spider and I think it is not possible to inspect such variables in the explorer. I disagree that my response does not answer the question at least partially, but I understand if you choose not to accept it. – Arn Mar 08 '20 at 11:55
  • Thanks for the feedback! The article is just there to provide a possible way to connect Jupyter to a Spyder kernel. In your opinion, have you answered that question? Don't worry about the points though. If you are the only one to answer then you'll get the bounty. – vestland Mar 08 '20 at 14:53
  • The final question you asked is "Any suggestions as to how I can take this further?" in reference to your attempt of following the procedure noted in the linked article. I provided the answer to that question. – Arn Mar 09 '20 at 14:51