You are probably familiar with connecting to a remote kernel using Jupyter notebooks, and it is great if your computer is not powerful enough to run things like deep learning training but you can connect to a more powerful machine. 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.
First, you need to make sure that the Spyder-kernels package is installed in the remote and the local computers. Here I’m using conda to manage my packages ( I think the new version of spyder comes with spyder-kernels pre-installed)
conda install spyder-kernels
Once you install the spyder-kernels you can start a kernel using python -m spyder_kernels.console but make sure you specify the public IP of the remote machine in the command
python -m spyder_kernels.console — matplotlib=’inline’ — ip=x.x.x.x -f=./remotemachine.json
Note the f= option, by default kernel configuration file is located in a temporary folder which you can check by issuing the command
but you can save the file in another location with -f option, here I chose the current directory.
Once the kernel is up and running, you can download the JSON file to the local machine using any sftp client.
The JSON file will look like this (don’t modify the file)
Open spyder in your local machine and click connect to an existing kernel from the Console window
Browse to the location were you downloaded the JSON file and open it.
Now you can run your code in the remote machine and see the variables in the variables window.
There is one caveat, you cannot run the entire code in the editor using the run button, as of now (Feb 2019), but you can highlight part of the code and run it.
There is an open issue (https://github.com/spyder-ide/spyder/issues/3065, https://github.com/spyder-ide/spyder/issues/3587, https://github.com/spyder-ide/spyder/issues/3323) regarding this, hopefully, the spyder team will resolve it soon