How do I remotely connect to a python kernel using spyder IDE. I've search online for instructions but i find any that help.

  • How do you even know this is possible? Surely there's documentation on it somewhere if you think it is... I've never heard of Spyder IDE personally, so without something to go on, there isn't much many of us can do to help.
    – Jacobm001
    Jan 26 '18 at 22:40

The steps below are confirmed to work using Spyder 3.1.4 IDE on a Debian Jessie or Ubuntu Xenial, to connect on a Raspberry Pi 2, using Raspbian Jessie, to run Python 2.7 scripts - however, I think they can work in any similar situation.


  1. You must be able to connect to the server(Pi) using ssh without a password
    (e.g. use ssh-copy-id or similar to copy your local key to the server).
  2. Spyder installed on your client.
  3. The ability of the client to mount a Pi's path (optional, but it will save you lots of effort) - if your client is *Nix, then sshfs, if it's windows then any similar program
  4. iPython installed on the server (Pi)
    I am not sure if the whole thing can work without iPython but, anyway, it's a nice thing to have: It's way better than the normal Python console...


  1. Using any means at hand (ssh, vnc, Teamviewer, physical access) start an iPython console on the server (Pi), using ipython or Pi's GUI.
    This will output something like:

    Python 2.7.9 (default, Sep 17 2017, 20:26:04)  
    Type "copyright", "credits" or "license" for more information.  
    IPython 2.3.0 -- An enhanced Interactive Python.  
    ?         -> Introduction and overview of IPython's features.  
    %quickref -> Quick reference.  
    help      -> Python's own help system.  
    object?   -> Details about 'object', use 'object??' for extra details.  
    %guiref   -> A brief reference about the graphical user interface.
  2. Issue a %connect_info command (this is known as "connect_info magic")
    This will output something like:

    In [1]: %connect_info  
      "stdin_port": 56159,  
      "ip": "",  
      "control_port": 59261,  
      "hb_port": 36977,  
      "signature_scheme": "hmac-sha256",  
      "key": "8c5d0c44-0eb1-5699-1db7-f0d175bde37f",  
      "shell_port": 55033,  
      "transport": "tcp",  
      "iopub_port": 54787 
    Paste the above JSON into a file, and connect with:  
        $> ipython <app> --existing <file>  
    or, if you are local, you can connect with just:  
        $> ipython <app> --existing kernel-14046.json  
    or even just:  
        $> ipython <app> --existing  
    if this is the most recent IPython session you have started.
  3. (Informative) This information is put in a json file (in Raspberry):

    $ sudo find / -name "kernel*.json"  

    And the contents of this file:

    $ cat /home/pi/.ipython/profile_default/security/kernel-23143.json  
    "stdin_port": 57511,  
    "ip": "",  
    "control_port": 52447,  
    "hb_port": 50009,  
    "signature_scheme": "hmac-sha256",  
    "key": "8c5d0c44-0eb1-5699-1db7-f0d175bde37f",  
    "shell_port": 54319,  
    "transport": "tcp",  
    "iopub_port": 46791  
  4. As it is stated in the instructions in the iPython console, you can paste the above info in a local json file and use this (see next step), so the existence of the server's json file is of little importance. By experience, however, it saves a lot of effort if this file and, more important, the (path to the) Python code you'll be creating on the server is mounted locally.
    In the client side:

    $ sudo mkdir /home/pi  

    this will contain the entire home dir of the server's user (pi) - a little extra care is due...

    $ sudo chown my_local_user:my_localgroup /home/pi  

    this allows the local user to have complete access to the server's (Pi's) home dir - YOU MUST BE CAREFUL what you do with it!
    Finally, mount pi's home:

    $ sshfs pi@server_IP:/home/pi /home/pi -o idmap=user -o compression=yes -o reconnect -o follow_symlinks
  5. From Spyder's "Consoles" menu, choose "Connect to an existing kernel"

  6. Use the browse button to the right of "Path to connection file or kernel id" and navigate to the locally mounted json file (since we have mounted pi's home in our /home/pi in step 3, the paths are identical, no matter if you call the json from the server or the local box - in my case: /home/pi/.ipython/profile_default/security/kernel-23143.json)
  7. Check "This is a remote kernel" checkbox - this will enable the following three fields
  8. In the "Host name" field input the ssh connection you use to connect to the server - eg pi@server_IP. You'll need to append :server_port only if the server listens to a non-default port.
  9. For the "Path to the ssh key file", browse to your local ssh key - mine is the /home/local_username/.ssh/id_rsa.pub (You may need to 'show hidden files' and select files of all types *.* - spyder is by default looking for .pem files)
  10. If you have set a passphrase for your key, enter it in the last field "Password..." - otherwise just leave it blank.
  11. When you hit OK, it will take a few seconds and a new iPython console will open inside spyder which, instead of being labeled something like Console 1/A, it will show server_user@server_IP.

I use the above solution very often, to connect my Ubuntu box with tons of resources and a big monitor to my Pi. For the time being I have no security concerns in this environment. However, mounting the entire pi's home locally screams for caution - perhaps it would be wiser to mount only the necessary subdirs.

That's it - enjoy!

While the above solution uses local resources to run Spyder, there is another approach to the task: Install Spyder on the Pi, issue an ssh -Y pi@the_pi_ip locally and type spyder - this will open Spyder's GUI locally, but Spyder itself will be running on the Pi (there will be big performance degradation).

  • Brilliant. I'll take a look tomorrow :-) Sep 23 '17 at 20:02
  • When i connect from the client(windows 7) to the pi( server) I receive the error "could not open ssh tunnel. The error was: Paramiko not available" 8. I beleive its standard? When I connect through putty, its the standard port - 9. Entered pi@ (i dont have SSH Key file) just the password for the pi user. - 10. tried ssh password for the username pi and leaving it blank. - 11. i receive the error "could not open ssh tunnel. The error was: Paramiko not available" Sep 24 '17 at 18:06
  • 8: It is. 9: You MUST setup password-less SSH - see prerequisite #1 - there is no way around it, as far as I know. 11: If memory serves, Paramiko is something you can pip-install. I'd google something like "Paramiko pip windows 7". If you don't find anything, let me know and I'll check my docs.
    – GregStef
    Sep 25 '17 at 6:29
  • ah i missed that one. I'll get on and test it :-) Sep 25 '17 at 18:08
  • Just to be sure, Paramiko would need to be installed on the client side only, not the server (Raspberry Pi)? Sep 25 '17 at 18:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.